-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TA#65669 [ADD] sales_team_account_journal (#380)
* TA#65669 [ADD] sales_team_account_journal * TA#65669 [ADD] sales_team_account_journal * TA#65669 [ADD] sales_team_account_journal --------- Co-authored-by: majouda <[email protected]>
- Loading branch information
1 parent
82c57cf
commit c99523f
Showing
19 changed files
with
264 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Sales Team Account Journal | ||
========================== | ||
This module allows to define a default sales journal on a sales team | ||
and assign this sales journal to all invoices linked to this sales team. | ||
|
||
Features | ||
-------- | ||
**New Sales Journal field on sales team** | ||
As a user in the Sales/Manager group, I go to `Sales > Configuration > Sales Teams`. | ||
I create a new sales team or click on an existing sales team. | ||
|
||
.. image:: static/description/sales_team_menu.png | ||
|
||
I see that a new `Sales Journal` field is available. | ||
|
||
.. image:: static/description/sales_journal_choices.png | ||
|
||
On hover, I see that the following help field is available: | ||
|
||
.. image:: static/description/sale_journal_helper.png | ||
|
||
I select the `Amazon Sale` journal and save. | ||
|
||
.. image:: static/description/sales_team_record.png | ||
|
||
Usage | ||
----- | ||
As the `Accounting > Billing Administrator` user, I go to a customer sales order | ||
for which the sales team is linked to Amazon Sale journal. | ||
I create the invoice and post it. | ||
|
||
.. image:: static/description/invoice_with_sales_team.png | ||
|
||
On the draft invoice, I see that the sales journal is Amazon Sale. | ||
|
||
.. image:: static/description/customer_invoice_journal.png | ||
|
||
Important notes | ||
--------------- | ||
-If the sales journal is not set on the sales team, vanilla behavior is applied. | ||
-If the currency of the journal defined on the sales team is different | ||
from the currency of the invoice created, the vanilla behavior applies | ||
(i.e. the system will assign to the invoice the first sales journal that is in the currency of the invoice). | ||
|
||
Contributors | ||
------------ | ||
* Numigi (tm) and all its contributors (https://bit.ly/numigiens) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Sales Team Account Journal", | ||
"version": "1.0.0", | ||
"author": "Numigi", | ||
"maintainer": "Numigi", | ||
"website": "https://bit.ly/numigi-com", | ||
"license": "AGPL-3", | ||
"category": "Sale", | ||
"depends": [ | ||
"account", | ||
"sales_team", | ||
], | ||
"summary": "Add a default sales journal on a sales team for invoices", | ||
"data": [ | ||
"views/crm_team_views.xml", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * sales_team_account_journal | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-05-30 06:03+0000\n" | ||
"PO-Revision-Date: 2024-05-30 06:03+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: sales_team_account_journal | ||
#: model:ir.model.fields,field_description:sales_team_account_journal.field_account_move__display_name | ||
#: model:ir.model.fields,field_description:sales_team_account_journal.field_crm_team__display_name | ||
msgid "Display Name" | ||
msgstr "Nom d'affichage" | ||
|
||
#. module: sales_team_account_journal | ||
#: model:ir.model.fields,field_description:sales_team_account_journal.field_account_move__id | ||
#: model:ir.model.fields,field_description:sales_team_account_journal.field_crm_team__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: sales_team_account_journal | ||
#: model:ir.model,name:sales_team_account_journal.model_account_move | ||
msgid "Journal Entry" | ||
msgstr "Pièce comptable" | ||
|
||
#. module: sales_team_account_journal | ||
#: model:ir.model.fields,field_description:sales_team_account_journal.field_account_move____last_update | ||
#: model:ir.model.fields,field_description:sales_team_account_journal.field_crm_team____last_update | ||
msgid "Last Modified on" | ||
msgstr "Dernière modification le" | ||
|
||
#. module: sales_team_account_journal | ||
#: model:ir.model.fields,field_description:sales_team_account_journal.field_crm_team__journal_id | ||
msgid "Sales Journal" | ||
msgstr "Journal de ventes" | ||
|
||
#. module: sales_team_account_journal | ||
#: model:ir.model,name:sales_team_account_journal.model_crm_team | ||
msgid "Sales Team" | ||
msgstr "Équipe commerciale" | ||
|
||
#. module: sales_team_account_journal | ||
#: model:ir.model.fields,help:sales_team_account_journal.field_crm_team__journal_id | ||
msgid "" | ||
"This Sales Journal will be set as default on all Sales related " | ||
"to this Sales Team. Only Sales type journals can be selected." | ||
msgstr "" | ||
"Ce journal de vente sera défini par défaut sur toutes les ventes liées " | ||
"à cette équipe commerciale. Seuls les journaux de type Ventes peuvent être sélectionnés." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import crm_team | ||
from . import account_move |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class AccountMove(models.Model): | ||
_inherit = "account.move" | ||
|
||
@api.onchange("team_id") | ||
def onchange_team_id(self): | ||
if ( | ||
self.team_id | ||
and self.team_id.journal_id | ||
and ( | ||
not self.team_id.journal_id.currency_id | ||
or self.team_id.journal_id.currency_id == self.currency_id | ||
) | ||
and self.team_id.journal_id.company_id == self.company_id | ||
): | ||
self.journal_id = self.team_id.journal_id | ||
|
||
@api.model | ||
def create(self, vals): | ||
rec = super(AccountMove, self).create(vals) | ||
if ( | ||
rec.team_id | ||
and rec.team_id.journal_id | ||
and ( | ||
not rec.team_id.journal_id.currency_id | ||
or rec.team_id.journal_id.currency_id == rec.currency_id | ||
) | ||
and rec.team_id.journal_id.company_id == rec.company_id | ||
): | ||
rec.journal_id = rec.team_id.journal_id.id | ||
return rec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models, fields | ||
|
||
|
||
class CrmTeam(models.Model): | ||
_inherit = "crm.team" | ||
|
||
journal_id = fields.Many2one( | ||
"account.journal", | ||
string="Sales Journal", | ||
ondelete="restrict", | ||
domain=[("type", "=", "sale")], | ||
check_company=True, | ||
help=( | ||
"This Sales Journal will be set as default on all Sales related \ | ||
to this Sales Team. Only Sales type journals can be selected.", | ||
), | ||
) |
Binary file added
BIN
+85.8 KB
sales_team_account_journal/static/description/customer_invoice_journal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+108 KB
sales_team_account_journal/static/description/invoice_with_sales_team.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+64.9 KB
sales_team_account_journal/static/description/sale_journal_helper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+63.9 KB
sales_team_account_journal/static/description/sales_journal_choices.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import test__account_move_journal |
52 changes: 52 additions & 0 deletions
52
sales_team_account_journal/tests/test__account_move_journal.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.tests.common import SavepointCase | ||
|
||
|
||
class AccountMoveJournal(SavepointCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.journal = cls.env["account.journal"].create( | ||
{ | ||
"name": "My Sale Journal", | ||
"type": "sale", | ||
"code": "MSJ", | ||
"currency_id": cls.env.ref("base.USD").id, | ||
} | ||
) | ||
cls.team_id = cls.env["crm.team"].create( | ||
{ | ||
"name": "Super Sales Team", | ||
"journal_id": cls.journal.id, | ||
} | ||
) | ||
|
||
def test__01_team_journal_exists(self): | ||
move = self.env["account.move"].create( | ||
{ | ||
"team_id": self.team_id.id, | ||
"currency_id": self.env.ref("base.USD").id, | ||
} | ||
) | ||
self.assertEqual(move.journal_id.name, self.journal.name) | ||
|
||
def test__02_team_journal_not_exists(self): | ||
self.team_id.journal_id = False | ||
move = self.env["account.move"].create( | ||
{ | ||
"currency_id": self.env.ref("base.USD").id, | ||
} | ||
) | ||
self.assertNotEqual(move.journal_id, self.journal) | ||
|
||
def test__03_team_journal_exists_but_different_currency(self): | ||
self.journal.currency_id = self.env.ref("base.EUR").id | ||
move = self.env["account.move"].create( | ||
{ | ||
"team_id": self.team_id.id, | ||
"currency_id": self.env.ref("base.USD").id, | ||
} | ||
) | ||
self.assertNotEqual(move.journal_id.name, self.journal.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="crm_team_view_form_inherit" model="ir.ui.view"> | ||
<field name="name">Add account journal on crm team form view</field> | ||
<field name="model">crm.team</field> | ||
<field name="inherit_id" ref="sales_team.crm_team_view_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//group[@name='right']" position="inside"> | ||
<field name="journal_id"/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |