From f6a5ff4ea9b1f1352e2329e907e2cfcd87c1aad7 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Tue, 15 Apr 2025 17:26:10 +0200 Subject: [PATCH 1/6] account_cutoff_base: analytic distribution Do not set analytic distribution to False in move creation to allow standard computation --- account_cutoff_base/models/account_cutoff.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/account_cutoff_base/models/account_cutoff.py b/account_cutoff_base/models/account_cutoff.py index ea600546baa..823b0e8617a 100644 --- a/account_cutoff_base/models/account_cutoff.py +++ b/account_cutoff_base/models/account_cutoff.py @@ -263,9 +263,12 @@ def _prepare_move(self, to_provision): } for k, v in zip(merge_keys, merge_values): value = v - if k == "analytic_distribution" and isinstance(v, str): - value = json.loads(value) - + if k == "analytic_distribution": + if not value: + # Drop from vals to allow computated field to compute + continue + elif isinstance(v, str): + value = json.loads(value) vals[k] = value movelines_to_create.append((0, 0, vals)) From 89daee6d2ae0d842389ac19ef14e8b3800a92856 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Fri, 11 Apr 2025 17:39:40 +0200 Subject: [PATCH 2/6] account_cutoff_accrual_order_base: product analytic Keep product on each move line. Set the move type to allow product_analytic to compute the right analytic account --- .../models/account_cutoff.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/account_cutoff_accrual_order_base/models/account_cutoff.py b/account_cutoff_accrual_order_base/models/account_cutoff.py index 184141cdecc..71289f7451a 100644 --- a/account_cutoff_accrual_order_base/models/account_cutoff.py +++ b/account_cutoff_accrual_order_base/models/account_cutoff.py @@ -87,6 +87,25 @@ def get_lines(self): _logger.debug("Prepare cutoff lines - next chunk") return res + def _get_merge_keys(self): + res = super()._get_merge_keys() + res += ["product_id"] + return res + + def _prepare_provision_line(self, cutoff_line): + vals = super()._prepare_provision_line(cutoff_line) + if cutoff_line.product_id: + vals["product_id"] = cutoff_line.product_id.id + return vals + + def create_move(self): + # set move as income or expense to be compatible with product_analytic + if self.cutoff_type in "accrued_revenue": + self = self.with_context(move_type="out_invoice") + elif self.cutoff_type in "accrued_expense": + self = self.with_context(move_type="in_invoice") + return super().create_move() + @api.model def _cron_cutoff(self, cutoff_type, model): # Cron is expected to run at begin of new period. We need the last day From 062a72a760e20be4d0e16d967797918e497b8e48 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Tue, 15 Apr 2025 16:43:09 +0200 Subject: [PATCH 3/6] [ADD] account_cutoff_accrual_sale_product_analytic add test glue module --- .../README.rst | 84 ++++ .../__init__.py | 0 .../__manifest__.py | 17 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 1 + .../static/description/index.html | 425 ++++++++++++++++++ .../tests/__init__.py | 1 + .../tests/test_cutoff_revenue.py | 61 +++ ...count_cutoff_accrual_sale_product_analytic | 1 + .../setup.py | 6 + 10 files changed, 597 insertions(+) create mode 100644 account_cutoff_accrual_sale_product_analytic/README.rst create mode 100644 account_cutoff_accrual_sale_product_analytic/__init__.py create mode 100644 account_cutoff_accrual_sale_product_analytic/__manifest__.py create mode 100644 account_cutoff_accrual_sale_product_analytic/readme/CONTRIBUTORS.rst create mode 100644 account_cutoff_accrual_sale_product_analytic/readme/DESCRIPTION.rst create mode 100644 account_cutoff_accrual_sale_product_analytic/static/description/index.html create mode 100644 account_cutoff_accrual_sale_product_analytic/tests/__init__.py create mode 100644 account_cutoff_accrual_sale_product_analytic/tests/test_cutoff_revenue.py create mode 120000 setup/account_cutoff_accrual_sale_product_analytic/odoo/addons/account_cutoff_accrual_sale_product_analytic create mode 100644 setup/account_cutoff_accrual_sale_product_analytic/setup.py diff --git a/account_cutoff_accrual_sale_product_analytic/README.rst b/account_cutoff_accrual_sale_product_analytic/README.rst new file mode 100644 index 00000000000..65fb2021838 --- /dev/null +++ b/account_cutoff_accrual_sale_product_analytic/README.rst @@ -0,0 +1,84 @@ +============================================= +Account Cut-off Accrual Sale Product Analytic +============================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e6ea6da9fe3bf4d5eb4f9d59a1b019ab7587e921d11c65ba85ea7ee414df1897 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/licence-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%2Faccount--closing-lightgray.png?logo=github + :target: https://github.com/OCA/account-closing/tree/16.0/account_cutoff_accrual_sale_product_analytic + :alt: OCA/account-closing +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-closing-16-0/account-closing-16-0-account_cutoff_accrual_sale_product_analytic + :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/account-closing&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Test module between account_cutoff_accrual_sale and product_analytic + +**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 +~~~~~~~ + +* BCIM + +Contributors +~~~~~~~~~~~~ + +* Jacques-Etienne Baudoux (BCIM) + +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. + +.. |maintainer-jbaudoux| image:: https://github.com/jbaudoux.png?size=40px + :target: https://github.com/jbaudoux + :alt: jbaudoux + +Current `maintainer `__: + +|maintainer-jbaudoux| + +This module is part of the `OCA/account-closing `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_cutoff_accrual_sale_product_analytic/__init__.py b/account_cutoff_accrual_sale_product_analytic/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/account_cutoff_accrual_sale_product_analytic/__manifest__.py b/account_cutoff_accrual_sale_product_analytic/__manifest__.py new file mode 100644 index 00000000000..53738df966c --- /dev/null +++ b/account_cutoff_accrual_sale_product_analytic/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2025 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +{ + "name": "Account Cut-off Accrual Sale Product Analytic", + "version": "16.0.1.0.0", + "category": "Accounting & Finance", + "license": "AGPL-3", + "summary": "Test Accrued Revenue on Sales Order with Product Analytic", + "author": "BCIM, Odoo Community Association (OCA)", + "maintainers": ["jbaudoux"], + "website": "https://github.com/OCA/account-closing", + "depends": ["account_cutoff_accrual_sale", "product_analytic"], + "installable": True, + "auto_install": True, + "application": False, +} diff --git a/account_cutoff_accrual_sale_product_analytic/readme/CONTRIBUTORS.rst b/account_cutoff_accrual_sale_product_analytic/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..3c6c5c696a8 --- /dev/null +++ b/account_cutoff_accrual_sale_product_analytic/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Jacques-Etienne Baudoux (BCIM) diff --git a/account_cutoff_accrual_sale_product_analytic/readme/DESCRIPTION.rst b/account_cutoff_accrual_sale_product_analytic/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..8d257aeffad --- /dev/null +++ b/account_cutoff_accrual_sale_product_analytic/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Test module between account_cutoff_accrual_sale and product_analytic diff --git a/account_cutoff_accrual_sale_product_analytic/static/description/index.html b/account_cutoff_accrual_sale_product_analytic/static/description/index.html new file mode 100644 index 00000000000..07d57b574d7 --- /dev/null +++ b/account_cutoff_accrual_sale_product_analytic/static/description/index.html @@ -0,0 +1,425 @@ + + + + + +Account Cut-off Accrual Sale Product Analytic + + + +
+

Account Cut-off Accrual Sale Product Analytic

+ + +

Beta License: AGPL-3 OCA/account-closing Translate me on Weblate Try me on Runboat

+

Test module between account_cutoff_accrual_sale and product_analytic

+

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

+
    +
  • BCIM
  • +
+
+
+

Contributors

+ +
+
+

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.

+

Current maintainer:

+

jbaudoux

+

This module is part of the OCA/account-closing project on GitHub.

+

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

+
+
+
+ + diff --git a/account_cutoff_accrual_sale_product_analytic/tests/__init__.py b/account_cutoff_accrual_sale_product_analytic/tests/__init__.py new file mode 100644 index 00000000000..34d4dd52a80 --- /dev/null +++ b/account_cutoff_accrual_sale_product_analytic/tests/__init__.py @@ -0,0 +1 @@ +from . import test_cutoff_revenue diff --git a/account_cutoff_accrual_sale_product_analytic/tests/test_cutoff_revenue.py b/account_cutoff_accrual_sale_product_analytic/tests/test_cutoff_revenue.py new file mode 100644 index 00000000000..1a698ed8fe1 --- /dev/null +++ b/account_cutoff_accrual_sale_product_analytic/tests/test_cutoff_revenue.py @@ -0,0 +1,61 @@ +# Copyright 2025 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from odoo.addons.account_cutoff_accrual_sale.tests.common import ( + TestAccountCutoffAccrualSaleCommon, +) + + +class TestAccountCutoffAccrualSale(TestAccountCutoffAccrualSaleCommon): + def test_revenue_so_analytic_distribution(self): + cutoff = self.revenue_cutoff + self.so.action_confirm() + cutoff.get_lines() + self.assertEqual(len(cutoff.line_ids), 1, "1 cutoff line should be found") + for line in cutoff.line_ids: + self.assertDictEqual( + line.analytic_distribution, + {str(self.analytic_account.id): self.price}, + "Analytic distribution is not correctly set", + ) + cutoff.create_move() + product_move_line = cutoff.move_id.line_ids.filtered("product_id") + self.assertEqual( + len(product_move_line), 1, "1 product move line should be found" + ) + self.assertDictEqual( + product_move_line.analytic_distribution, + {str(self.analytic_account.id): 100}, + "Analytic distribution is not correctly set", + ) + + def test_revenue_product_analytic_distribution(self): + cutoff = self.revenue_cutoff + self.so.order_line.analytic_distribution = False + analytic_account_2 = self.env["account.analytic.account"].create( + { + "name": "analytic_account 2", + "plan_id": self.default_plan.id, + "company_id": False, + } + ) + self.products.income_analytic_account_id = analytic_account_2 + self.so.action_confirm() + cutoff.get_lines() + self.assertEqual(len(cutoff.line_ids), 1, "1 cutoff line should be found") + for line in cutoff.line_ids: + self.assertFalse( + line.analytic_distribution, + "Analytic distribution is not correctly set", + ) + cutoff.create_move() + product_move_line = cutoff.move_id.line_ids.filtered("product_id") + self.assertEqual( + len(product_move_line), 1, "1 product move line should be found" + ) + self.assertDictEqual( + product_move_line.analytic_distribution, + {str(analytic_account_2.id): 100}, + "Analytic distribution is not correctly set", + ) diff --git a/setup/account_cutoff_accrual_sale_product_analytic/odoo/addons/account_cutoff_accrual_sale_product_analytic b/setup/account_cutoff_accrual_sale_product_analytic/odoo/addons/account_cutoff_accrual_sale_product_analytic new file mode 120000 index 00000000000..7f647e2b0c6 --- /dev/null +++ b/setup/account_cutoff_accrual_sale_product_analytic/odoo/addons/account_cutoff_accrual_sale_product_analytic @@ -0,0 +1 @@ +../../../../account_cutoff_accrual_sale_product_analytic \ No newline at end of file diff --git a/setup/account_cutoff_accrual_sale_product_analytic/setup.py b/setup/account_cutoff_accrual_sale_product_analytic/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/account_cutoff_accrual_sale_product_analytic/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From a78a02e69c181302b24c10b2940abc7268b9ced7 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Wed, 16 Apr 2025 09:42:10 +0200 Subject: [PATCH 4/6] account_cutoff_accrual_purchase_stock: fix test classes --- account_cutoff_accrual_purchase_stock/tests/common.py | 8 +++++--- .../tests/test_cutoff_expense.py | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/account_cutoff_accrual_purchase_stock/tests/common.py b/account_cutoff_accrual_purchase_stock/tests/common.py index 954de644ccd..179b54148ca 100644 --- a/account_cutoff_accrual_purchase_stock/tests/common.py +++ b/account_cutoff_accrual_purchase_stock/tests/common.py @@ -13,7 +13,7 @@ ) -class TestAccountCutoffAccrualPurchaseCommon(TestAccountCutoffAccrualOrderCommon): +class TestAccountCutoffAccrualPurchaseStockCommon(TestAccountCutoffAccrualOrderCommon): @classmethod def setUpClass(cls): super().setUpClass() @@ -37,6 +37,8 @@ def setUpClass(cls): } ) cls.tax_purchase.account_accrued_expense_id = cls.cutoff_account + cls.price = 100 + cls.qty = 5 cls.po = cls.env["purchase.order"].create( { "partner_id": cls.partner.id, @@ -45,9 +47,9 @@ def setUpClass(cls): { "name": p.name, "product_id": p.id, - "product_qty": 5, + "product_qty": cls.qty, "product_uom": p.uom_po_id.id, - "price_unit": 100, + "price_unit": cls.price, "date_planned": fields.Date.to_string( datetime.today() + relativedelta(days=-15) ), diff --git a/account_cutoff_accrual_purchase_stock/tests/test_cutoff_expense.py b/account_cutoff_accrual_purchase_stock/tests/test_cutoff_expense.py index 32086851548..33383388418 100644 --- a/account_cutoff_accrual_purchase_stock/tests/test_cutoff_expense.py +++ b/account_cutoff_accrual_purchase_stock/tests/test_cutoff_expense.py @@ -5,10 +5,12 @@ from odoo import fields -from .common import TestAccountCutoffAccrualPurchaseCommon +from .common import TestAccountCutoffAccrualPurchaseStockCommon -class TestAccountCutoffAccrualPurchase(TestAccountCutoffAccrualPurchaseCommon): +class TestAccountCutoffAccrualPurchaseStock( + TestAccountCutoffAccrualPurchaseStockCommon +): def test_accrued_expense_empty(self): """Test cutoff when there is no PO.""" cutoff = self.expense_cutoff From 3e5526b29df213ac9619c39a1b30f1feb95b8648 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Tue, 15 Apr 2025 23:00:50 +0200 Subject: [PATCH 5/6] [ADD] account_cutoff_accrual_purchase_product_analytic --- .../README.rst | 84 ++++ .../__init__.py | 0 .../__manifest__.py | 17 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 1 + .../static/description/index.html | 425 ++++++++++++++++++ .../tests/__init__.py | 1 + .../tests/test_cutoff_expense.py | 65 +++ ...ff_accrual_purchase_stock_product_analytic | 1 + .../setup.py | 6 + 10 files changed, 601 insertions(+) create mode 100644 account_cutoff_accrual_purchase_stock_product_analytic/README.rst create mode 100644 account_cutoff_accrual_purchase_stock_product_analytic/__init__.py create mode 100644 account_cutoff_accrual_purchase_stock_product_analytic/__manifest__.py create mode 100644 account_cutoff_accrual_purchase_stock_product_analytic/readme/CONTRIBUTORS.rst create mode 100644 account_cutoff_accrual_purchase_stock_product_analytic/readme/DESCRIPTION.rst create mode 100644 account_cutoff_accrual_purchase_stock_product_analytic/static/description/index.html create mode 100644 account_cutoff_accrual_purchase_stock_product_analytic/tests/__init__.py create mode 100644 account_cutoff_accrual_purchase_stock_product_analytic/tests/test_cutoff_expense.py create mode 120000 setup/account_cutoff_accrual_purchase_stock_product_analytic/odoo/addons/account_cutoff_accrual_purchase_stock_product_analytic create mode 100644 setup/account_cutoff_accrual_purchase_stock_product_analytic/setup.py diff --git a/account_cutoff_accrual_purchase_stock_product_analytic/README.rst b/account_cutoff_accrual_purchase_stock_product_analytic/README.rst new file mode 100644 index 00000000000..f75a733681f --- /dev/null +++ b/account_cutoff_accrual_purchase_stock_product_analytic/README.rst @@ -0,0 +1,84 @@ +================================================= +Account Cut-off Accrual Purchase Product Analytic +================================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e6ea6da9fe3bf4d5eb4f9d59a1b019ab7587e921d11c65ba85ea7ee414df1897 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/licence-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%2Faccount--closing-lightgray.png?logo=github + :target: https://github.com/OCA/account-closing/tree/16.0/account_cutoff_accrual_purchase_stock_product_analytic + :alt: OCA/account-closing +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-closing-16-0/account-closing-16-0-account_cutoff_accrual_purchase_stock_product_analytic + :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/account-closing&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Test module between account_cutoff_accrual_purchase_stock and product_analytic + +**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 +~~~~~~~ + +* BCIM + +Contributors +~~~~~~~~~~~~ + +* Jacques-Etienne Baudoux (BCIM) + +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. + +.. |maintainer-jbaudoux| image:: https://github.com/jbaudoux.png?size=40px + :target: https://github.com/jbaudoux + :alt: jbaudoux + +Current `maintainer `__: + +|maintainer-jbaudoux| + +This module is part of the `OCA/account-closing `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_cutoff_accrual_purchase_stock_product_analytic/__init__.py b/account_cutoff_accrual_purchase_stock_product_analytic/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/account_cutoff_accrual_purchase_stock_product_analytic/__manifest__.py b/account_cutoff_accrual_purchase_stock_product_analytic/__manifest__.py new file mode 100644 index 00000000000..3abe78b7268 --- /dev/null +++ b/account_cutoff_accrual_purchase_stock_product_analytic/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2025 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +{ + "name": "Account Cut-off Accrual Purchase Product Analytic", + "version": "16.0.1.0.0", + "category": "Accounting & Finance", + "license": "AGPL-3", + "summary": "Test Accrued Expense on Purchase Order with Product Analytic", + "author": "BCIM, Odoo Community Association (OCA)", + "maintainers": ["jbaudoux"], + "website": "https://github.com/OCA/account-closing", + "depends": ["account_cutoff_accrual_purchase_stock", "product_analytic"], + "installable": True, + "auto_install": True, + "application": False, +} diff --git a/account_cutoff_accrual_purchase_stock_product_analytic/readme/CONTRIBUTORS.rst b/account_cutoff_accrual_purchase_stock_product_analytic/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..3c6c5c696a8 --- /dev/null +++ b/account_cutoff_accrual_purchase_stock_product_analytic/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Jacques-Etienne Baudoux (BCIM) diff --git a/account_cutoff_accrual_purchase_stock_product_analytic/readme/DESCRIPTION.rst b/account_cutoff_accrual_purchase_stock_product_analytic/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..bb1707b1999 --- /dev/null +++ b/account_cutoff_accrual_purchase_stock_product_analytic/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Test module between account_cutoff_accrual_purchase_stock and product_analytic diff --git a/account_cutoff_accrual_purchase_stock_product_analytic/static/description/index.html b/account_cutoff_accrual_purchase_stock_product_analytic/static/description/index.html new file mode 100644 index 00000000000..510b6c16f03 --- /dev/null +++ b/account_cutoff_accrual_purchase_stock_product_analytic/static/description/index.html @@ -0,0 +1,425 @@ + + + + + +Account Cut-off Accrual Purchase Product Analytic + + + +
+

Account Cut-off Accrual Purchase Product Analytic

+ + +

Beta License: AGPL-3 OCA/account-closing Translate me on Weblate Try me on Runboat

+

Test module between account_cutoff_accrual_purchase_stock and product_analytic

+

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

+
    +
  • BCIM
  • +
+
+
+

Contributors

+ +
+
+

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.

+

Current maintainer:

+

jbaudoux

+

This module is part of the OCA/account-closing project on GitHub.

+

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

+
+
+
+ + diff --git a/account_cutoff_accrual_purchase_stock_product_analytic/tests/__init__.py b/account_cutoff_accrual_purchase_stock_product_analytic/tests/__init__.py new file mode 100644 index 00000000000..a6a5b7582d6 --- /dev/null +++ b/account_cutoff_accrual_purchase_stock_product_analytic/tests/__init__.py @@ -0,0 +1 @@ +from . import test_cutoff_expense diff --git a/account_cutoff_accrual_purchase_stock_product_analytic/tests/test_cutoff_expense.py b/account_cutoff_accrual_purchase_stock_product_analytic/tests/test_cutoff_expense.py new file mode 100644 index 00000000000..fed390ede4d --- /dev/null +++ b/account_cutoff_accrual_purchase_stock_product_analytic/tests/test_cutoff_expense.py @@ -0,0 +1,65 @@ +# Copyright 2025 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from odoo.addons.account_cutoff_accrual_purchase_stock.tests.common import ( + TestAccountCutoffAccrualPurchaseStockCommon, +) + + +class TestAccountCutoffAccrualPurchaseStockProductAnalytic( + TestAccountCutoffAccrualPurchaseStockCommon +): + def test_revenue_po_analytic_distribution(self): + cutoff = self.expense_cutoff + self._confirm_po_and_do_picking(2) + cutoff.get_lines() + self.assertEqual(len(cutoff.line_ids), 2, "2 cutoff line should be found") + for line in cutoff.line_ids: + self.assertDictEqual( + line.analytic_distribution, + {str(self.analytic_account.id): self.price}, + "Analytic distribution is not correctly set", + ) + cutoff.create_move() + product_move_line = cutoff.move_id.line_ids.filtered("product_id") + self.assertEqual( + len(product_move_line), 2, "2 product move line should be found" + ) + for line in product_move_line: + self.assertDictEqual( + line.analytic_distribution, + {str(self.analytic_account.id): 100}, + "Analytic distribution is not correctly set", + ) + + def test_revenue_product_analytic_distribution(self): + cutoff = self.expense_cutoff + self.po.order_line.analytic_distribution = False + analytic_account_2 = self.env["account.analytic.account"].create( + { + "name": "analytic_account 2", + "plan_id": self.default_plan.id, + "company_id": False, + } + ) + self.products.expense_analytic_account_id = analytic_account_2 + self._confirm_po_and_do_picking(2) + cutoff.get_lines() + self.assertEqual(len(cutoff.line_ids), 2, "2 cutoff line should be found") + for line in cutoff.line_ids: + self.assertFalse( + line.analytic_distribution, + "Analytic distribution is not correctly set", + ) + cutoff.create_move() + product_move_line = cutoff.move_id.line_ids.filtered("product_id") + self.assertEqual( + len(product_move_line), 2, "2 product move line should be found" + ) + for line in product_move_line: + self.assertDictEqual( + line.analytic_distribution, + {str(analytic_account_2.id): 100}, + "Analytic distribution is not correctly set", + ) diff --git a/setup/account_cutoff_accrual_purchase_stock_product_analytic/odoo/addons/account_cutoff_accrual_purchase_stock_product_analytic b/setup/account_cutoff_accrual_purchase_stock_product_analytic/odoo/addons/account_cutoff_accrual_purchase_stock_product_analytic new file mode 120000 index 00000000000..cb969b4a5d0 --- /dev/null +++ b/setup/account_cutoff_accrual_purchase_stock_product_analytic/odoo/addons/account_cutoff_accrual_purchase_stock_product_analytic @@ -0,0 +1 @@ +../../../../account_cutoff_accrual_purchase_stock_product_analytic \ No newline at end of file diff --git a/setup/account_cutoff_accrual_purchase_stock_product_analytic/setup.py b/setup/account_cutoff_accrual_purchase_stock_product_analytic/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/account_cutoff_accrual_purchase_stock_product_analytic/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From 61833cfed6f2b24ccbe6771b66b8cd5f1c4e178c Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Tue, 15 Apr 2025 17:29:52 +0200 Subject: [PATCH 6/6] [DO NOT MERGE] test-requirement.txt --- test-requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test-requirements.txt diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000000..06a993da172 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-product_analytic @ git+https://github.com/OCA/account-analytic.git@refs/pull/768/head#subdirectory=setup/product_analytic