diff --git a/purchase_analytic_global/README.rst b/purchase_analytic_global/README.rst new file mode 100644 index 00000000000..60ba3da3757 --- /dev/null +++ b/purchase_analytic_global/README.rst @@ -0,0 +1,100 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +================================== +Purchase - Analytic Account Global +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a0f9dc4b6ce66852de767aeebef547d00a60f696a4755da649c0e488c2ff34c3 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/19.0/purchase_analytic_global + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-workflow-19-0/purchase-workflow-19-0-purchase_analytic_global + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds an analytic account on the purchases that is applied on +all the lines distributions. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Camptocamp + +Contributors +------------ + +- `Camptocamp `__: + + - Guewen Baconnier + - Yannick Vaucher + - Iryna Vyshnevska + - Maksym Yankin + +- `ERP Harbor `__: + + - Sudhir Arya + +- `Trobz `__: + + - Phuc Tran + +Other credits +------------- + +The migration of this module from 15.0 to 18.0 was financially supported +by Camptocamp + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_analytic_global/__init__.py b/purchase_analytic_global/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/purchase_analytic_global/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_analytic_global/__manifest__.py b/purchase_analytic_global/__manifest__.py new file mode 100644 index 00000000000..fd5fcb72277 --- /dev/null +++ b/purchase_analytic_global/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2014-2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +{ + "name": "Purchase - Analytic Account Global", + "version": "19.0.1.0.0", + "author": "Camptocamp, Odoo Community Association (OCA)", + "maintainer": "Camptocamp", + "license": "AGPL-3", + "category": "Purchase Management", + "complexity": "easy", + "depends": ["purchase"], + "website": "https://github.com/OCA/purchase-workflow", + "data": ["views/purchase_order.xml"], + "installable": True, + "auto_install": False, +} diff --git a/purchase_analytic_global/i18n/es.po b/purchase_analytic_global/i18n/es.po new file mode 100644 index 00000000000..4211387a8f7 --- /dev/null +++ b/purchase_analytic_global/i18n/es.po @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_analytic_global +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-07-18 18:08+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__account_analytic_id +msgid "Analytic Account" +msgstr "cuenta analítica" + +#. module: purchase_analytic_global +#: model:ir.model,name:purchase_analytic_global.model_purchase_order +msgid "Purchase Order" +msgstr "orden de compra" + +#. module: purchase_analytic_global +#: model:ir.model.fields,help:purchase_analytic_global.field_purchase_order__account_analytic_id +msgid "" +"This account will be propagated to all lines, if you need to use different " +"accounts, define the account at line level." +msgstr "" +"Esta cuenta se propagará a todas las líneas, si necesita utilizar diferentes" +" cuentas, defina la cuenta a nivel de línea." diff --git a/purchase_analytic_global/i18n/fr.po b/purchase_analytic_global/i18n/fr.po new file mode 100644 index 00000000000..afda5610282 --- /dev/null +++ b/purchase_analytic_global/i18n/fr.po @@ -0,0 +1,38 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * purchase_analytic_global +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-09-01 10:04+0000\n" +"PO-Revision-Date: 2015-09-01 10:04+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__account_analytic_id +msgid "Analytic Account" +msgstr "Compte analytique" + +#. module: purchase_analytic_global +#: model:ir.model,name:purchase_analytic_global.model_purchase_order +msgid "Purchase Order" +msgstr "Commande d'achat" + +#. module: purchase_analytic_global +#: model:ir.model.fields,help:purchase_analytic_global.field_purchase_order__account_analytic_id +#, fuzzy +msgid "" +"This account will be propagated to all lines, if you need to use different " +"accounts, define the account at line level." +msgstr "" +"Le compte analytique sera défini sur toutes les lignes. Afin d'utiliser des " +"comptes différents sur les lignes, veuillez laisser ce champ vide et les " +"définir manuellement sur les lignes." diff --git a/purchase_analytic_global/i18n/it.po b/purchase_analytic_global/i18n/it.po new file mode 100644 index 00000000000..8be759919e7 --- /dev/null +++ b/purchase_analytic_global/i18n/it.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_analytic_global +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-03-07 07:10+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.10.2\n" + +#. module: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__analytic_distribution +msgid "Analytic Distribution" +msgstr "Distribuzione analitica" + +#. module: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__analytic_precision +msgid "Analytic Precision" +msgstr "Precisione analitica" + +#. module: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__distribution_analytic_account_ids +msgid "Distribution Analytic Account" +msgstr "Conto distribuzione analitica" + +#. module: purchase_analytic_global +#: model:ir.model,name:purchase_analytic_global.model_purchase_order +msgid "Purchase Order" +msgstr "Ordine di acquisto" + +#. module: purchase_analytic_global +#: model:ir.model.fields,help:purchase_analytic_global.field_purchase_order__analytic_distribution +msgid "" +"This analytic distribution will be propagated to all lines analytic " +"distributions, if you need to use different analytic distribution, define it" +" at line level." +msgstr "" +"Questa distribuzione analitica verrà propagata a tutte le righe di " +"distribuzione analitica; se è necessario utilizzare una distribuzione " +"analitica diversa, definirla a livello di riga." diff --git a/purchase_analytic_global/i18n/nl.po b/purchase_analytic_global/i18n/nl.po new file mode 100644 index 00000000000..ab4e1073407 --- /dev/null +++ b/purchase_analytic_global/i18n/nl.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_analytic_global +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-11-11 15:42+0000\n" +"Last-Translator: Bosd \n" +"Language-Team: none\n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.10.4\n" + +#. module: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__analytic_distribution +msgid "Analytic Distribution" +msgstr "Analytische Verdeling" + +#. module: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__analytic_precision +msgid "Analytic Precision" +msgstr "Analytische Precisie" + +#. module: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__distribution_analytic_account_ids +msgid "Distribution Analytic Account" +msgstr "Analytische Rekening voor Verdeling" + +#. module: purchase_analytic_global +#: model:ir.model,name:purchase_analytic_global.model_purchase_order +msgid "Purchase Order" +msgstr "Inkooporder" + +#. module: purchase_analytic_global +#: model:ir.model.fields,help:purchase_analytic_global.field_purchase_order__analytic_distribution +msgid "" +"This analytic distribution will be propagated to all lines analytic " +"distributions, if you need to use different analytic distribution, define it" +" at line level." +msgstr "" +"Deze analytische verdeling wordt doorgezet naar de analytische verdelingen " +"van alle regels, indien u een andere analytische verdeling wilt gebruiken, " +"definieer deze dan op regelniveau." diff --git a/purchase_analytic_global/i18n/pt_BR.po b/purchase_analytic_global/i18n/pt_BR.po new file mode 100644 index 00000000000..0eef52d6b69 --- /dev/null +++ b/purchase_analytic_global/i18n/pt_BR.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_analytic_global +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" + +#. module: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__analytic_distribution +msgid "Analytic Distribution" +msgstr "" + +#. module: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__analytic_precision +msgid "Analytic Precision" +msgstr "" + +#. module: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__distribution_analytic_account_ids +msgid "Distribution Analytic Account" +msgstr "" + +#. module: purchase_analytic_global +#: model:ir.model,name:purchase_analytic_global.model_purchase_order +msgid "Purchase Order" +msgstr "" + +#. module: purchase_analytic_global +#: model:ir.model.fields,help:purchase_analytic_global.field_purchase_order__analytic_distribution +msgid "" +"This analytic distribution will be propagated to all lines analytic " +"distributions, if you need to use different analytic distribution, define it" +" at line level." +msgstr "" diff --git a/purchase_analytic_global/i18n/purchase_analytic_global.pot b/purchase_analytic_global/i18n/purchase_analytic_global.pot new file mode 100644 index 00000000000..032c8549752 --- /dev/null +++ b/purchase_analytic_global/i18n/purchase_analytic_global.pot @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_analytic_global +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \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: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__analytic_distribution +msgid "Analytic Distribution" +msgstr "" + +#. module: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__analytic_precision +msgid "Analytic Precision" +msgstr "" + +#. module: purchase_analytic_global +#: model:ir.model.fields,field_description:purchase_analytic_global.field_purchase_order__distribution_analytic_account_ids +msgid "Distribution Analytic Account" +msgstr "" + +#. module: purchase_analytic_global +#: model:ir.model,name:purchase_analytic_global.model_purchase_order +msgid "Purchase Order" +msgstr "" + +#. module: purchase_analytic_global +#: model:ir.model.fields,help:purchase_analytic_global.field_purchase_order__analytic_distribution +msgid "" +"This analytic distribution will be propagated to all lines analytic " +"distributions, if you need to use different analytic distribution, define it" +" at line level." +msgstr "" diff --git a/purchase_analytic_global/models/__init__.py b/purchase_analytic_global/models/__init__.py new file mode 100644 index 00000000000..9f03530643d --- /dev/null +++ b/purchase_analytic_global/models/__init__.py @@ -0,0 +1 @@ +from . import purchase_order diff --git a/purchase_analytic_global/models/purchase_order.py b/purchase_analytic_global/models/purchase_order.py new file mode 100644 index 00000000000..8cfb018219c --- /dev/null +++ b/purchase_analytic_global/models/purchase_order.py @@ -0,0 +1,40 @@ +# Copyright 2014-2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import api, fields, models + + +class PurchaseOrder(models.Model): + _name = "purchase.order" + _inherit = ["purchase.order", "analytic.mixin"] + + analytic_distribution = fields.Json( + inverse="_inverse_analytic_distribution", + help="This analytic distribution will be propagated to all lines " + "analytic distributions, if you need to use different " + "analytic distribution, define it at line level.", + ) + + @api.depends("order_line.analytic_distribution") + def _compute_analytic_distribution(self): + """Set the analytic distribution on the order based on its order lines. + + If all order lines have the same analytic distribution, + then set it on the order, otherwise left the field empty. + """ + res = super()._compute_analytic_distribution() + for order in self: + distributions = order.mapped("order_line.analytic_distribution") + if distributions and all( + distribute == distributions[0] for distribute in distributions + ): + order.analytic_distribution = distributions[0] + else: + order.analytic_distribution = False + return res + + def _inverse_analytic_distribution(self): + """Propagate the analytic distribution to order lines if set on the order""" + for order in self: + if order.analytic_distribution: + order.order_line.analytic_distribution = order.analytic_distribution diff --git a/purchase_analytic_global/pyproject.toml b/purchase_analytic_global/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/purchase_analytic_global/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/purchase_analytic_global/readme/CONTRIBUTORS.md b/purchase_analytic_global/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..b661e56d2e0 --- /dev/null +++ b/purchase_analytic_global/readme/CONTRIBUTORS.md @@ -0,0 +1,11 @@ +- [Camptocamp](https://camptocamp.com): + - Guewen Baconnier \<\> + - Yannick Vaucher \<\> + - Iryna Vyshnevska \<\> + - Maksym Yankin \<\> + +- [ERP Harbor](https://erpharbor.com): + - Sudhir Arya \<\> + +- [Trobz](https://trobz.com): + - Phuc Tran \<\> diff --git a/purchase_analytic_global/readme/CREDITS.md b/purchase_analytic_global/readme/CREDITS.md new file mode 100644 index 00000000000..43edcd32e19 --- /dev/null +++ b/purchase_analytic_global/readme/CREDITS.md @@ -0,0 +1,2 @@ +The migration of this module from 15.0 to 18.0 was financially supported +by Camptocamp diff --git a/purchase_analytic_global/readme/DESCRIPTION.md b/purchase_analytic_global/readme/DESCRIPTION.md new file mode 100644 index 00000000000..11612d21403 --- /dev/null +++ b/purchase_analytic_global/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module adds an analytic account on the purchases that is applied on +all the lines distributions. diff --git a/purchase_analytic_global/static/description/icon.png b/purchase_analytic_global/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_analytic_global/static/description/icon.png differ diff --git a/purchase_analytic_global/static/description/index.html b/purchase_analytic_global/static/description/index.html new file mode 100644 index 00000000000..a6893c06ad5 --- /dev/null +++ b/purchase_analytic_global/static/description/index.html @@ -0,0 +1,450 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Purchase - Analytic Account Global

+ +

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

+

This module adds an analytic account on the purchases that is applied on +all the lines distributions.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The migration of this module from 15.0 to 18.0 was financially supported +by Camptocamp

+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/purchase-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/purchase_analytic_global/tests/__init__.py b/purchase_analytic_global/tests/__init__.py new file mode 100644 index 00000000000..a30cb3293cf --- /dev/null +++ b/purchase_analytic_global/tests/__init__.py @@ -0,0 +1 @@ +from . import test_purchase_analytic_global diff --git a/purchase_analytic_global/tests/test_purchase_analytic_global.py b/purchase_analytic_global/tests/test_purchase_analytic_global.py new file mode 100644 index 00000000000..3c33537f659 --- /dev/null +++ b/purchase_analytic_global/tests/test_purchase_analytic_global.py @@ -0,0 +1,103 @@ +# Copyright 2025 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from datetime import date + +from odoo.addons.base.tests.common import BaseCommon + + +class TestPurchaseAnalyticGlobal(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.analytic_plan = cls.env["account.analytic.plan"].create({"name": "Plan"}) + # Create a product directly instead of using external XML ID + # (product.product_product_4 doesn't exist in Odoo 19) + cls.product = cls.env["product.product"].create( + { + "name": "Test Product", + "type": "consu", + "list_price": 100.0, + "standard_price": 50.0, + } + ) + cls.partner = cls.env["res.partner"].create({"name": "Test Partner"}) + vals_list = [ + {"name": "Analytic Account 1", "plan_id": cls.analytic_plan.id}, + {"name": "Analytic Account 2", "plan_id": cls.analytic_plan.id}, + {"name": "Analytic Account 3", "plan_id": cls.analytic_plan.id}, + ] + cls.account1, cls.account2, cls.account3 = cls.env[ + "account.analytic.account" + ].create(vals_list) + cls.purchase_order = cls.env["purchase.order"].create( + {"partner_id": cls.partner.id} + ) + line_vals_list = [ + { + "name": cls.product.name, + "product_id": cls.product.id, + "order_id": cls.purchase_order.id, + "product_qty": 10, + "price_unit": 50, + "date_planned": date.today(), + } + for _ in range(3) + ] + cls.order_line = cls.env["purchase.order.line"].create(line_vals_list) + cls.line1, cls.line2, cls.line3 = cls.order_line + + def test_00_purchase_order_compute_distribution(self): + """Test the analytic distribution is computed correctly. + + 1. Check the analytic distribution is the same on order lines + and is set on the purchase order. + 2. Check the analytic distribution is different on order lines + and is not set on the purchase order. + 3. Check no distribution on order lines and on the purchase order. + """ + self.assertFalse( + any(self.purchase_order.order_line.mapped("analytic_distribution")), + "No distribution", + ) + self.assertFalse(self.purchase_order.analytic_distribution, "No distribution") + self.order_line.analytic_distribution = {self.account1.id: 25} + self.assertEqual( + self.purchase_order.analytic_distribution, + {str(self.account1.id): 25.0}, + "Same distribution", + ) + self.line2.analytic_distribution = {self.account2.id: 50} + self.line3.analytic_distribution = False + self.assertFalse( + self.purchase_order.analytic_distribution, "Different distribution" + ) + # Set the same distribution on the order lines + self.order_line.analytic_distribution = {self.account3.id: 55} + self.assertEqual( + self.purchase_order.analytic_distribution, + {str(self.account3.id): 55.0}, + "Same distribution", + ) + # Remove the distribution on the order lines + self.order_line.analytic_distribution = False + self.assertFalse(self.purchase_order.analytic_distribution, "No distribution") + + def test_01_purchase_order_inverse_distribution(self): + """Test the analytic distribution is inversed correctly. + + Check distribution set on the purchase order + is propagated to order lines. + """ + self.assertFalse( + any(self.purchase_order.order_line.mapped("analytic_distribution")), + "No distribution", + ) + self.purchase_order.analytic_distribution = {self.account1.id: 50} + self.assertTrue( + all( + line.analytic_distribution == self.purchase_order.analytic_distribution + for line in self.purchase_order.order_line + ), + "Same distribution", + ) diff --git a/purchase_analytic_global/views/purchase_order.xml b/purchase_analytic_global/views/purchase_order.xml new file mode 100644 index 00000000000..571ff830d56 --- /dev/null +++ b/purchase_analytic_global/views/purchase_order.xml @@ -0,0 +1,18 @@ + + + + purchase.order.form + purchase.order + + + + + + + +