diff --git a/mrp_unbuild_valuation_layer_link/README.rst b/mrp_unbuild_valuation_layer_link/README.rst new file mode 100644 index 000000000..45fc98903 --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/README.rst @@ -0,0 +1,84 @@ +=================================== +Valuation layers for unbuild orders +=================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:01ea7c714c0e67fec71c2d5c5553abdadfc724218dcfaaaf03fe87f0d534630b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-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%2Fmanufacture-lightgray.png?logo=github + :target: https://github.com/OCA/manufacture/tree/14.0/mrp_unbuild_valuation_layer_link + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-mrp_unbuild_valuation_layer_link + :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/manufacture&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module shows a valuation button in the unbuild orders that is connected with valuation layers of the order. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Go to *Manufacturing > Operations > Unbuild Orders* and select one that has the status = "Done". +#. Press the button *Valuation*. + +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 +~~~~~~~~~~~~ + +* `ForgeFlow `_: + + * Thiago Mulero + +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/manufacture `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mrp_unbuild_valuation_layer_link/__init__.py b/mrp_unbuild_valuation_layer_link/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mrp_unbuild_valuation_layer_link/__manifest__.py b/mrp_unbuild_valuation_layer_link/__manifest__.py new file mode 100644 index 000000000..ecd98a93e --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/__manifest__.py @@ -0,0 +1,12 @@ +{ + "name": "Valuation layers for unbuild orders", + "version": "16.0.1.0.1", + "license": "LGPL-3", + "category": "Manufacture", + "summary": "Unbuild orders display the connected valuation layers", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/manufacture", + "depends": ["mrp_account"], + "data": ["views/mrp_unbuild_views.xml"], + "installable": True, +} diff --git a/mrp_unbuild_valuation_layer_link/i18n/it.po b/mrp_unbuild_valuation_layer_link/i18n/it.po new file mode 100644 index 000000000..efb418b26 --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/i18n/it.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_unbuild_valuation_layer_link +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-12-20 13:44+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.14.1\n" + +#. module: mrp_unbuild_valuation_layer_link +#: model:ir.model.fields,field_description:mrp_unbuild_valuation_layer_link.field_mrp_unbuild__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: mrp_unbuild_valuation_layer_link +#: model:ir.model.fields,field_description:mrp_unbuild_valuation_layer_link.field_mrp_unbuild__id +msgid "ID" +msgstr "ID" + +#. module: mrp_unbuild_valuation_layer_link +#: model:ir.model.fields,field_description:mrp_unbuild_valuation_layer_link.field_mrp_unbuild____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: mrp_unbuild_valuation_layer_link +#: model:ir.model,name:mrp_unbuild_valuation_layer_link.model_mrp_unbuild +msgid "Unbuild Order" +msgstr "Smonta ordine" + +#. module: mrp_unbuild_valuation_layer_link +#: model_terms:ir.ui.view,arch_db:mrp_unbuild_valuation_layer_link.mrp_unbuild_form_view_inherited +msgid "Valuation" +msgstr "Valutazione" diff --git a/mrp_unbuild_valuation_layer_link/i18n/mrp_unbuild_valuation_layer_link.pot b/mrp_unbuild_valuation_layer_link/i18n/mrp_unbuild_valuation_layer_link.pot new file mode 100644 index 000000000..95d0a2bd3 --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/i18n/mrp_unbuild_valuation_layer_link.pot @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_unbuild_valuation_layer_link +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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: mrp_unbuild_valuation_layer_link +#: model:ir.model.fields,field_description:mrp_unbuild_valuation_layer_link.field_mrp_unbuild__display_name +msgid "Display Name" +msgstr "" + +#. module: mrp_unbuild_valuation_layer_link +#: model:ir.model.fields,field_description:mrp_unbuild_valuation_layer_link.field_mrp_unbuild__id +msgid "ID" +msgstr "" + +#. module: mrp_unbuild_valuation_layer_link +#: model:ir.model.fields,field_description:mrp_unbuild_valuation_layer_link.field_mrp_unbuild____last_update +msgid "Last Modified on" +msgstr "" + +#. module: mrp_unbuild_valuation_layer_link +#: model:ir.model,name:mrp_unbuild_valuation_layer_link.model_mrp_unbuild +msgid "Unbuild Order" +msgstr "" + +#. module: mrp_unbuild_valuation_layer_link +#: model_terms:ir.ui.view,arch_db:mrp_unbuild_valuation_layer_link.mrp_unbuild_form_view_inherited +msgid "Valuation" +msgstr "" diff --git a/mrp_unbuild_valuation_layer_link/models/__init__.py b/mrp_unbuild_valuation_layer_link/models/__init__.py new file mode 100644 index 000000000..d576b9508 --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/models/__init__.py @@ -0,0 +1 @@ +from . import mrp_unbuild diff --git a/mrp_unbuild_valuation_layer_link/models/mrp_unbuild.py b/mrp_unbuild_valuation_layer_link/models/mrp_unbuild.py new file mode 100644 index 000000000..fbda9e2fb --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/models/mrp_unbuild.py @@ -0,0 +1,27 @@ +from ast import literal_eval + +from odoo import models + + +class MrpUnbuild(models.Model): + _inherit = "mrp.unbuild" + + def action_view_stock_valuation_layers(self): + self.ensure_one() + domain = [ + ( + "id", + "in", + ( + self.produce_line_ids + self.consume_line_ids + ).stock_valuation_layer_ids.ids, + ) + ] + action = self.env["ir.actions.actions"]._for_xml_id( + "stock_account.stock_valuation_layer_action" + ) + context = literal_eval(action["context"]) + context.update(self.env.context) + context["no_at_date"] = True + context["search_default_group_by_product_id"] = False + return dict(action, domain=domain, context=context) diff --git a/mrp_unbuild_valuation_layer_link/readme/CONTRIBUTORS.rst b/mrp_unbuild_valuation_layer_link/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..da18dd75a --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `ForgeFlow `_: + + * Thiago Mulero diff --git a/mrp_unbuild_valuation_layer_link/readme/DESCRIPTION.rst b/mrp_unbuild_valuation_layer_link/readme/DESCRIPTION.rst new file mode 100644 index 000000000..0c8ff26e3 --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module shows a valuation button in the unbuild orders that is connected with valuation layers of the order. diff --git a/mrp_unbuild_valuation_layer_link/readme/USAGE.rst b/mrp_unbuild_valuation_layer_link/readme/USAGE.rst new file mode 100644 index 000000000..0f6886aff --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/readme/USAGE.rst @@ -0,0 +1,2 @@ +#. Go to *Manufacturing > Operations > Unbuild Orders* and select one that has the status = "Done". +#. Press the button *Valuation*. diff --git a/mrp_unbuild_valuation_layer_link/static/description/icon.png b/mrp_unbuild_valuation_layer_link/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mrp_unbuild_valuation_layer_link/static/description/icon.png differ diff --git a/mrp_unbuild_valuation_layer_link/static/description/index.html b/mrp_unbuild_valuation_layer_link/static/description/index.html new file mode 100644 index 000000000..1ea39e136 --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/static/description/index.html @@ -0,0 +1,432 @@ + + + + + + +Valuation layers for unbuild orders + + + +
+

Valuation layers for unbuild orders

+ + +

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

+

This module shows a valuation button in the unbuild orders that is connected with valuation layers of the order.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to Manufacturing > Operations > Unbuild Orders and select one that has the status = “Done”.
  2. +
  3. Press the button Valuation.
  4. +
+
+
+

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

+ +
+
+

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/manufacture project on GitHub.

+

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

+
+
+
+ + diff --git a/mrp_unbuild_valuation_layer_link/tests/__init__.py b/mrp_unbuild_valuation_layer_link/tests/__init__.py new file mode 100644 index 000000000..5327ba4df --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/tests/__init__.py @@ -0,0 +1 @@ +from . import test_mrp__unbuild_valuation_layer_link diff --git a/mrp_unbuild_valuation_layer_link/tests/test_mrp__unbuild_valuation_layer_link.py b/mrp_unbuild_valuation_layer_link/tests/test_mrp__unbuild_valuation_layer_link.py new file mode 100644 index 000000000..d3a9c05f3 --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/tests/test_mrp__unbuild_valuation_layer_link.py @@ -0,0 +1,61 @@ +from odoo.tests import Form + +from odoo.addons.mrp.tests.common import TestMrpCommon + + +class TestUnbuild(TestMrpCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.stock_location = cls.env.ref("stock.stock_location_stock") + cls.env.ref("base.group_user").write( + {"implied_ids": [(4, cls.env.ref("stock.group_production_lot").id)]} + ) + + def test_unbuild_with_valuation_layer(self): + """This test creates an Unbuild order from a Manufacturing order and then check if the + valuation button links to the valuation layer of the order. + """ + mo, bom, p_final, p1, p2 = self.generate_mo() + + self.env["stock.quant"]._update_available_quantity(p1, self.stock_location, 100) + self.env["stock.quant"]._update_available_quantity(p2, self.stock_location, 5) + mo.action_assign() + + mo_form = Form(mo) + mo_form.qty_producing = 5.0 + mo = mo_form.save() + mo.button_mark_done() + layers_before_unbuild = ( + self.env["stock.move"].search([]).stock_valuation_layer_ids.ids + ) + + x = Form(self.env["mrp.unbuild"]) + x.product_id = p_final + x.bom_id = bom + x.product_qty = 5 + unbuild = x.save() + unbuild.action_unbuild() + layers_after_unbuild = ( + self.env["stock.move"].search([]).stock_valuation_layer_ids.ids + ) + + result = unbuild.action_view_stock_valuation_layers() + domain = result["domain"] + unbuild_valuation_layers = domain[0][2] + difference_layers = list(set(layers_after_unbuild) - set(layers_before_unbuild)) + + self.assertTrue( + difference_layers, "There should be new layers after doing the unbuild" + ) + self.assertEqual( + result["res_model"], + "stock.valuation.layer", + "You should access to the model stock.valuation.layer", + ) + self.assertEqual( + sorted(difference_layers), + sorted(unbuild_valuation_layers), + "You should have as domain the ids of the stock valuation belonging " + "to the ids of the stock moves of produce_line and consume_line", + ) diff --git a/mrp_unbuild_valuation_layer_link/views/mrp_unbuild_views.xml b/mrp_unbuild_valuation_layer_link/views/mrp_unbuild_views.xml new file mode 100644 index 000000000..d082ffc81 --- /dev/null +++ b/mrp_unbuild_valuation_layer_link/views/mrp_unbuild_views.xml @@ -0,0 +1,20 @@ + + + mrp.unbuild.view.inherited - Button Valuation + mrp.unbuild + + + +