diff --git a/ddmrp_exclude_moves_adu_calc_sales/README.rst b/ddmrp_exclude_moves_adu_calc_sales/README.rst new file mode 100644 index 000000000..3e6d020d8 --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/README.rst @@ -0,0 +1,90 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +================================== +DDMRP Exclude Moves ADU Calc Sales +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:04ebcda948ba6e3e263541215705a43a8d4a8af9eae5a9c2ebd15848ba2c5899 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fddmrp-lightgray.png?logo=github + :target: https://github.com/OCA/ddmrp/tree/19.0/ddmrp_exclude_moves_adu_calc_sales + :alt: OCA/ddmrp +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/ddmrp-19-0/ddmrp-19-0-ddmrp_exclude_moves_adu_calc_sales + :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/ddmrp&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends ddmrp_exclude_moves_adu_calc to be able to mark sale +order lines to be excluded from adu calculation + +**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 +------- + +* ForgeFlow + +Contributors +------------ + +- Lois Rilo +- David Jiménez + +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-DavidJForgeFlow| image:: https://github.com/DavidJForgeFlow.png?size=40px + :target: https://github.com/DavidJForgeFlow + :alt: DavidJForgeFlow + +Current `maintainer `__: + +|maintainer-DavidJForgeFlow| + +This module is part of the `OCA/ddmrp `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/ddmrp_exclude_moves_adu_calc_sales/__init__.py b/ddmrp_exclude_moves_adu_calc_sales/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/ddmrp_exclude_moves_adu_calc_sales/__manifest__.py b/ddmrp_exclude_moves_adu_calc_sales/__manifest__.py new file mode 100644 index 000000000..6752a8b2e --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +{ + "name": "DDMRP Exclude Moves ADU Calc Sales", + "summary": "DDMRP Exclude Moves ADU Calc integration with Sales app.", + "version": "19.0.1.0.0", + "development_status": "Beta", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "maintainers": ["DavidJForgeFlow"], + "website": "https://github.com/OCA/ddmrp", + "category": "Warehouse Management", + "depends": ["sale_stock", "ddmrp_exclude_moves_adu_calc"], + "data": ["views/sale_order_view.xml"], + "license": "LGPL-3", + "installable": True, +} diff --git a/ddmrp_exclude_moves_adu_calc_sales/i18n/es.po b/ddmrp_exclude_moves_adu_calc_sales/i18n/es.po new file mode 100644 index 000000000..c64c7126f --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/i18n/es.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * ddmrp_exclude_moves_adu_calc_sales +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-03-20 20:35+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: ddmrp_exclude_moves_adu_calc_sales +#: model:ir.model.fields,field_description:ddmrp_exclude_moves_adu_calc_sales.field_sale_order_line__exclude_from_adu +msgid "Exclude from ADU calculation" +msgstr "Excluir del cálculo ADU" + +#. module: ddmrp_exclude_moves_adu_calc_sales +#: model:ir.model.fields,help:ddmrp_exclude_moves_adu_calc_sales.field_sale_order_line__exclude_from_adu +msgid "" +"If this flag is set related stock moves will be excluded from ADU " +"calculation" +msgstr "" +"Si se activa este indicador, los movimientos de existencias relacionados se " +"excluirán del cálculo de ADU" + +#. module: ddmrp_exclude_moves_adu_calc_sales +#: model:ir.model,name:ddmrp_exclude_moves_adu_calc_sales.model_sale_order_line +msgid "Sales Order Line" +msgstr "Línea de Orden de Venta" + +#. module: ddmrp_exclude_moves_adu_calc_sales +#: model:ir.model,name:ddmrp_exclude_moves_adu_calc_sales.model_stock_move +msgid "Stock Move" +msgstr "Movimiento de Almacén" diff --git a/ddmrp_exclude_moves_adu_calc_sales/i18n/it.po b/ddmrp_exclude_moves_adu_calc_sales/i18n/it.po new file mode 100644 index 000000000..baf979b71 --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/i18n/it.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * ddmrp_exclude_moves_adu_calc_sales +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-03-04 09:35+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 4.17\n" + +#. module: ddmrp_exclude_moves_adu_calc_sales +#: model:ir.model.fields,field_description:ddmrp_exclude_moves_adu_calc_sales.field_sale_order_line__exclude_from_adu +msgid "Exclude from ADU calculation" +msgstr "Escudere dal calcolo ADU" + +#. module: ddmrp_exclude_moves_adu_calc_sales +#: model:ir.model.fields,help:ddmrp_exclude_moves_adu_calc_sales.field_sale_order_line__exclude_from_adu +msgid "" +"If this flag is set related stock moves will be excluded from ADU " +"calculation" +msgstr "" +"Se questa opzione è attiva, i movimenti di magazzino relativi verranno " +"esclusi dal calcolo ADU" + +#. module: ddmrp_exclude_moves_adu_calc_sales +#: model:ir.model,name:ddmrp_exclude_moves_adu_calc_sales.model_sale_order_line +msgid "Sales Order Line" +msgstr "Riga ordine di vendita" + +#. module: ddmrp_exclude_moves_adu_calc_sales +#: model:ir.model,name:ddmrp_exclude_moves_adu_calc_sales.model_stock_move +msgid "Stock Move" +msgstr "Movimento di magazzino" diff --git a/ddmrp_exclude_moves_adu_calc_sales/models/__init__.py b/ddmrp_exclude_moves_adu_calc_sales/models/__init__.py new file mode 100644 index 000000000..8eb9d1d40 --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/models/__init__.py @@ -0,0 +1 @@ +from . import sale_order_line diff --git a/ddmrp_exclude_moves_adu_calc_sales/models/sale_order_line.py b/ddmrp_exclude_moves_adu_calc_sales/models/sale_order_line.py new file mode 100644 index 000000000..af10efa89 --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/models/sale_order_line.py @@ -0,0 +1,28 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import fields, models + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + exclude_from_adu = fields.Boolean( + string="Exclude from ADU calculation", + compute="_compute_exclude_from_adu", + inverse="_inverse_exclude_from_adu", + copy=False, + help="If this flag is set related stock moves will be excluded from " + "ADU calculation", + ) + + def _compute_exclude_from_adu(self): + for rec in self: + rec.exclude_from_adu = all(move.exclude_from_adu for move in rec.move_ids) + + def _inverse_exclude_from_adu(self): + for rec in self: + if rec.exclude_from_adu: + rec.move_ids.write({"exclude_from_adu": True}) + else: + rec.move_ids.write({"exclude_from_adu": False}) diff --git a/ddmrp_exclude_moves_adu_calc_sales/pyproject.toml b/ddmrp_exclude_moves_adu_calc_sales/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/ddmrp_exclude_moves_adu_calc_sales/readme/CONTRIBUTORS.md b/ddmrp_exclude_moves_adu_calc_sales/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..c77e7c6de --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Lois Rilo \<\> +- David Jiménez \<\> diff --git a/ddmrp_exclude_moves_adu_calc_sales/readme/DESCRIPTION.md b/ddmrp_exclude_moves_adu_calc_sales/readme/DESCRIPTION.md new file mode 100644 index 000000000..a8cef1512 --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module extends ddmrp_exclude_moves_adu_calc to be able to mark sale +order lines to be excluded from adu calculation diff --git a/ddmrp_exclude_moves_adu_calc_sales/static/description/icon.png b/ddmrp_exclude_moves_adu_calc_sales/static/description/icon.png new file mode 100644 index 000000000..90c92e98d Binary files /dev/null and b/ddmrp_exclude_moves_adu_calc_sales/static/description/icon.png differ diff --git a/ddmrp_exclude_moves_adu_calc_sales/static/description/index.html b/ddmrp_exclude_moves_adu_calc_sales/static/description/index.html new file mode 100644 index 000000000..9e489cc9f --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/static/description/index.html @@ -0,0 +1,433 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

DDMRP Exclude Moves ADU Calc Sales

+ +

Beta License: LGPL-3 OCA/ddmrp Translate me on Weblate Try me on Runboat

+

This module extends ddmrp_exclude_moves_adu_calc to be able to mark sale +order lines to be excluded from adu calculation

+

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

+
    +
  • ForgeFlow
  • +
+
+ +
+

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:

+

DavidJForgeFlow

+

This module is part of the OCA/ddmrp project on GitHub.

+

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

+
+
+
+
+ + diff --git a/ddmrp_exclude_moves_adu_calc_sales/tests/__init__.py b/ddmrp_exclude_moves_adu_calc_sales/tests/__init__.py new file mode 100644 index 000000000..06cd57239 --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/tests/__init__.py @@ -0,0 +1 @@ +from . import test_ddmrp_exclude_moves_adu_calc_sales diff --git a/ddmrp_exclude_moves_adu_calc_sales/tests/test_ddmrp_exclude_moves_adu_calc_sales.py b/ddmrp_exclude_moves_adu_calc_sales/tests/test_ddmrp_exclude_moves_adu_calc_sales.py new file mode 100644 index 000000000..879642ea5 --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/tests/test_ddmrp_exclude_moves_adu_calc_sales.py @@ -0,0 +1,87 @@ +# Copyright 2024 ForgeFlow (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + + +import odoo.tests.common as common + + +class TestDdmrp(common.TransactionCase): + def setUp(self): + super().setUp() + self.env = self.env(context=dict(self.env.context, tracking_disable=True)) + + # Models + self.productModel = self.env["product.product"] + self.bufferModel = self.env["stock.buffer"] + + # Refs + self.main_company = self.env.ref("base.main_company") + self.warehouse = self.env.ref("stock.warehouse0") + self.stock_location = self.env.ref("stock.stock_location_stock") + self.uom_unit = self.env.ref("uom.product_uom_unit") + self.buffer_profile_pur = self.env.ref( + "ddmrp.stock_buffer_profile_replenish_purchased_short_low" + ) + + self.product_a = self.productModel.create( + { + "name": "product A", + "standard_price": 1, + "is_storable": True, + "uom_id": self.uom_unit.id, + "default_code": "A", + } + ) + + self.customer = self.env["res.partner"].create( + { + "name": "Caroline Customer", + "email": "customer@example.com", + } + ) + + def create_sale_order(self): + return self.env["sale.order"].create( + { + "partner_id": self.customer.id, + "order_line": [ + (0, 0, ope) + for ope in [ + { + "name": p.name, + "product_id": p.id, + "product_uom_qty": 2, + "product_uom_id": p.uom_id.id, + "price_unit": 10, + } + for p in self.product_a + ] + ], + } + ) + + def test_01_exclude_so_from_adu(self): + method = self.env.ref("ddmrp.adu_calculation_method_past_120") + self.bufferModel.create( + { + "buffer_profile_id": self.buffer_profile_pur.id, + "product_id": self.product_a.id, + "location_id": self.stock_location.id, + "warehouse_id": self.warehouse.id, + "qty_multiple": 0.0, + "dlt": 10, + "adu_calculation_method": method.id, + "adu_fixed": 4, + } + ) + so = self.create_sale_order() + so.action_confirm() + self.assertFalse(so.order_line.exclude_from_adu) + self.assertFalse(so.picking_ids.move_ids.exclude_from_adu) + so.order_line.write({"exclude_from_adu": True}) + self.assertTrue(so.order_line.exclude_from_adu) + self.assertTrue(so.picking_ids.move_ids.exclude_from_adu) + so.picking_ids.move_ids._toggle_exclude_from_adu() + so.order_line.invalidate_recordset() + self.assertFalse(so.order_line.exclude_from_adu) + self.assertFalse(so.picking_ids.move_ids.exclude_from_adu) diff --git a/ddmrp_exclude_moves_adu_calc_sales/views/sale_order_view.xml b/ddmrp_exclude_moves_adu_calc_sales/views/sale_order_view.xml new file mode 100644 index 000000000..ecb3ad28e --- /dev/null +++ b/ddmrp_exclude_moves_adu_calc_sales/views/sale_order_view.xml @@ -0,0 +1,20 @@ + + + + + sale.order.form - ddmrp_exclude_moves_adu_calc_sales + sale.order + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..6d059a3da --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +# DO NOT MERGE — temporary pin until the ddmrp_exclude_moves_adu_calc 19.0 MIG lands. +odoo-addon-ddmrp_exclude_moves_adu_calc @ git+https://github.com/ledoent/ddmrp.git@19.0-mig-ddmrp_exclude_moves_adu_calc#subdirectory=ddmrp_exclude_moves_adu_calc