diff --git a/account_move_ordering_contacts/__init__.py b/account_move_ordering_contacts/__init__.py new file mode 100644 index 00000000000..69f7babdfb1 --- /dev/null +++ b/account_move_ordering_contacts/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/account_move_ordering_contacts/__manifest__.py b/account_move_ordering_contacts/__manifest__.py new file mode 100644 index 00000000000..66f94bebb01 --- /dev/null +++ b/account_move_ordering_contacts/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2021 Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Acccount Move Ordering Contacts", + "version": "14.0.1.0.0", + "summary": "Display original customers when creating invoices from" + " multiple sale orders.", + "author": "Camptocamp, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-invoicing", + "license": "AGPL-3", + "category": "Accounting & Finance", + "depends": ["account", "sale"], + "data": ["views/account_move.xml"], + "installable": True, +} diff --git a/account_move_ordering_contacts/models/__init__.py b/account_move_ordering_contacts/models/__init__.py new file mode 100644 index 00000000000..9c0a4213854 --- /dev/null +++ b/account_move_ordering_contacts/models/__init__.py @@ -0,0 +1 @@ +from . import account_move diff --git a/account_move_ordering_contacts/models/account_move.py b/account_move_ordering_contacts/models/account_move.py new file mode 100644 index 00000000000..859386b1a81 --- /dev/null +++ b/account_move_ordering_contacts/models/account_move.py @@ -0,0 +1,26 @@ +# Copyright 2021 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from odoo import api, fields, models + + +class AccountMove(models.Model): + _inherit = "account.move" + + ordering_contact_ids = fields.Many2many( + comodel_name="res.partner", + relation="account_move_ordering_contact_rel", + column1="account_move_id", + column2="res_partner_id", + compute="_compute_ordering_contact_ids", + store=True, + string="Ordering Contacts", + ) + + @api.depends("move_type", "invoice_line_ids.sale_line_ids.order_id.partner_id") + def _compute_ordering_contact_ids(self): + for move in self: + move.ordering_contact_ids = ( + move.move_type == "out_invoice" + and move.invoice_line_ids.mapped("sale_line_ids.order_id.partner_id") + ) diff --git a/account_move_ordering_contacts/readme/CONTRIBUTORS.rst b/account_move_ordering_contacts/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..60641f5f92c --- /dev/null +++ b/account_move_ordering_contacts/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Camptocamp `_ + + * Silvio Gregorini diff --git a/account_move_ordering_contacts/readme/CREDITS.rst b/account_move_ordering_contacts/readme/CREDITS.rst new file mode 100644 index 00000000000..f5cc070c78e --- /dev/null +++ b/account_move_ordering_contacts/readme/CREDITS.rst @@ -0,0 +1,3 @@ +The development of this module has been financially supported by: + +* Camptocamp diff --git a/account_move_ordering_contacts/readme/DESCRIPTION.rst b/account_move_ordering_contacts/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..f886be002da --- /dev/null +++ b/account_move_ordering_contacts/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +When invoicing multiple sale orders at the same time, they may be grouped into +a single invoice. When it happens, it is hard to retrieve who the original SO +partners were. + +This module helps by retrieving such partners and showing them into the invoice +form view, alongside the invoice partner itself. diff --git a/account_move_ordering_contacts/static/description/icon.png b/account_move_ordering_contacts/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/account_move_ordering_contacts/static/description/icon.png differ diff --git a/account_move_ordering_contacts/views/account_move.xml b/account_move_ordering_contacts/views/account_move.xml new file mode 100644 index 00000000000..74b4303340f --- /dev/null +++ b/account_move_ordering_contacts/views/account_move.xml @@ -0,0 +1,36 @@ + + + + + view.account.invoice.filter.inherit + account.move + + + + + + + + + + view.move.form.inherit + account.move + + + + + + + + + diff --git a/setup/account_move_ordering_contacts/odoo/addons/account_move_ordering_contacts b/setup/account_move_ordering_contacts/odoo/addons/account_move_ordering_contacts new file mode 120000 index 00000000000..0876ec41994 --- /dev/null +++ b/setup/account_move_ordering_contacts/odoo/addons/account_move_ordering_contacts @@ -0,0 +1 @@ +../../../../account_move_ordering_contacts \ No newline at end of file diff --git a/setup/account_move_ordering_contacts/setup.py b/setup/account_move_ordering_contacts/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/account_move_ordering_contacts/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)