diff --git a/account_move_line_manufacture_info/README.rst b/account_move_line_manufacture_info/README.rst new file mode 100644 index 000000000..d219ed493 --- /dev/null +++ b/account_move_line_manufacture_info/README.rst @@ -0,0 +1,82 @@ +========================================= +Account Move Line Manufacture Information +========================================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fmanufacture-lightgray.png?logo=github + :target: https://github.com/OCA/manufacture/tree/13.0/account_move_line_manufacture_info + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-13-0/manufacture-13-0-account_move_line_manufacture_info + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/129/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the manufacture information to any account move lines generated by a +manufacture operation such as a manufacturing order or an unbuild order. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +* In the manufacture order the user will be able to access the account + move lines that are related to the MO. +* In the unbuild order the user will be able to access the account + move lines that are related to the UO. + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Adria Gil + +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/account_move_line_manufacture_info/__init__.py b/account_move_line_manufacture_info/__init__.py new file mode 100644 index 000000000..cfc40a3ea --- /dev/null +++ b/account_move_line_manufacture_info/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models +from . import tests diff --git a/account_move_line_manufacture_info/__manifest__.py b/account_move_line_manufacture_info/__manifest__.py new file mode 100644 index 000000000..70390c92e --- /dev/null +++ b/account_move_line_manufacture_info/__manifest__.py @@ -0,0 +1,18 @@ +# © 2019 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Account Move Line Manufacture Information", + "version": "13.0.1.0.0", + "depends": ["stock_account", "mrp"], + "author": "ForgeFlow, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/manufacture", + "category": "Manufacture Management", + "installable": True, + "license": "AGPL-3", + "data": [ + "security/ir.model.access.csv", + "views/account_move_line_view.xml", + "views/mrp_production_views.xml", + "views/mrp_unbuild_views.xml", + ], +} diff --git a/account_move_line_manufacture_info/i18n/account_move_line_manufacture_info.pot b/account_move_line_manufacture_info/i18n/account_move_line_manufacture_info.pot new file mode 100644 index 000000000..9a14a3bf0 --- /dev/null +++ b/account_move_line_manufacture_info/i18n/account_move_line_manufacture_info.pot @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_line_manufacture_info +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.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: account_move_line_manufacture_info +#: model:ir.actions.act_window,name:account_move_line_manufacture_info.action_mrp_account_moves +#: model:ir.actions.act_window,name:account_move_line_manufacture_info.action_mrp_uo_account_moves +#: model_terms:ir.ui.view,arch_db:account_move_line_manufacture_info.mrp_production_form_view +#: model_terms:ir.ui.view,arch_db:account_move_line_manufacture_info.mrp_unbuild_form_view +msgid "Account Moves" +msgstr "" + +#. module: account_move_line_manufacture_info +#: model:ir.model,name:account_move_line_manufacture_info.model_account_move_line +msgid "Journal Item" +msgstr "" + +#. module: account_move_line_manufacture_info +#: model:ir.model.fields,field_description:account_move_line_manufacture_info.field_account_move_line__manufacture_order_id +msgid "Manufacture Order" +msgstr "" + +#. module: account_move_line_manufacture_info +#: model:ir.model,name:account_move_line_manufacture_info.model_stock_move +msgid "Stock Move" +msgstr "" + +#. module: account_move_line_manufacture_info +#: model:ir.model.fields,field_description:account_move_line_manufacture_info.field_account_move_line__unbuild_order_id +msgid "Unbuild Order" +msgstr "" + diff --git a/account_move_line_manufacture_info/models/__init__.py b/account_move_line_manufacture_info/models/__init__.py new file mode 100644 index 000000000..58072e841 --- /dev/null +++ b/account_move_line_manufacture_info/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import account_move_line +from . import stock_move diff --git a/account_move_line_manufacture_info/models/account_move_line.py b/account_move_line_manufacture_info/models/account_move_line.py new file mode 100644 index 000000000..4bad4a958 --- /dev/null +++ b/account_move_line_manufacture_info/models/account_move_line.py @@ -0,0 +1,19 @@ +# © 2019 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + manufacture_order_id = fields.Many2one( + comodel_name="mrp.production", + string="Manufacture Order", + copy=False, + index=True, + ) + + unbuild_order_id = fields.Many2one( + comodel_name="mrp.unbuild", string="Unbuild Order", copy=False, index=True + ) diff --git a/account_move_line_manufacture_info/models/stock_move.py b/account_move_line_manufacture_info/models/stock_move.py new file mode 100644 index 000000000..1267fb168 --- /dev/null +++ b/account_move_line_manufacture_info/models/stock_move.py @@ -0,0 +1,27 @@ +# © 2019 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, models + + +class StockMove(models.Model): + _inherit = "stock.move" + + @api.model + def _prepare_account_move_line( + self, qty, cost, credit_account_id, debit_account_id, description + ): + res = super(StockMove, self)._prepare_account_move_line( + qty, cost, credit_account_id, debit_account_id, description + ) + for line in res: + if self.production_id: + line[2]["manufacture_order_id"] = self.production_id.id + elif self.raw_material_production_id: + line[2]["manufacture_order_id"] = self.raw_material_production_id.id + line[2]["name"] = self.raw_material_production_id.name + elif self.unbuild_id: + line[2]["unbuild_order_id"] = self.unbuild_id.id + elif self.consume_unbuild_id: + line[2]["unbuild_order_id"] = self.consume_unbuild_id.id + return res diff --git a/account_move_line_manufacture_info/readme/CONTRIBUTORS.rst b/account_move_line_manufacture_info/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..be192c531 --- /dev/null +++ b/account_move_line_manufacture_info/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Adria Gil diff --git a/account_move_line_manufacture_info/readme/DESCRIPTION.rst b/account_move_line_manufacture_info/readme/DESCRIPTION.rst new file mode 100644 index 000000000..5b570af66 --- /dev/null +++ b/account_move_line_manufacture_info/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module adds the manufacture information to any account move lines generated by a +manufacture operation such as a manufacturing order or an unbuild order. diff --git a/account_move_line_manufacture_info/readme/USAGE.rst b/account_move_line_manufacture_info/readme/USAGE.rst new file mode 100644 index 000000000..413e4bdc5 --- /dev/null +++ b/account_move_line_manufacture_info/readme/USAGE.rst @@ -0,0 +1,4 @@ +* In the manufacture order the user will be able to access the account + move lines that are related to the MO. +* In the unbuild order the user will be able to access the account + move lines that are related to the UO. diff --git a/account_move_line_manufacture_info/security/ir.model.access.csv b/account_move_line_manufacture_info/security/ir.model.access.csv new file mode 100644 index 000000000..15b56c191 --- /dev/null +++ b/account_move_line_manufacture_info/security/ir.model.access.csv @@ -0,0 +1,8 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_account_move_line, account.move.line,account.model_account_move_line,mrp.group_mrp_manager,1,0,0,0 +access_mrp_production_account_invoice,mrp.production account invoice,mrp.model_mrp_production,account.group_account_invoice,1,0,0,0 +access_mrp_production_account_user,mrp.production account user,mrp.model_mrp_production,account.group_account_user,1,0,0,0 +access_mrp_production_account_manager,mrp.production account user,mrp.model_mrp_production,account.group_account_manager,1,0,0,0 +access_mrp_unbuild_account_invoice,mrp.unbuild account invoice,mrp.model_mrp_unbuild,account.group_account_invoice,1,0,0,0 +access_mrp_unbuild_account_user,mrp.unbuild account user,mrp.model_mrp_unbuild,account.group_account_user,1,0,0,0 +access_mrp_unbuild_account_manager,mrp.unbuild account user,mrp.model_mrp_unbuild,account.group_account_manager,1,0,0,0 diff --git a/account_move_line_manufacture_info/static/description/icon.png b/account_move_line_manufacture_info/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_move_line_manufacture_info/static/description/icon.png differ diff --git a/account_move_line_manufacture_info/static/description/index.html b/account_move_line_manufacture_info/static/description/index.html new file mode 100644 index 000000000..2fb17d762 --- /dev/null +++ b/account_move_line_manufacture_info/static/description/index.html @@ -0,0 +1,430 @@ + + + + + + +Account Move Line Manufacture Information + + + +
+

Account Move Line Manufacture Information

+ + +

Beta License: AGPL-3 OCA/manufacture Translate me on Weblate Try me on Runbot

+

This module adds the manufacture information to any account move lines generated by a +manufacture operation such as a manufacturing order or an unbuild order.

+

Table of contents

+ +
+

Usage

+
    +
  • In the manufacture order the user will be able to access the account +move lines that are related to the MO.
  • +
  • In the unbuild order the user will be able to access the account +move lines that are related to the UO.
  • +
+
+
+

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 smashing 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.

+

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/account_move_line_manufacture_info/tests/__init__.py b/account_move_line_manufacture_info/tests/__init__.py new file mode 100644 index 000000000..38f00b802 --- /dev/null +++ b/account_move_line_manufacture_info/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_account_move_line_manufacture_info diff --git a/account_move_line_manufacture_info/tests/test_account_move_line_manufacture_info.py b/account_move_line_manufacture_info/tests/test_account_move_line_manufacture_info.py new file mode 100644 index 000000000..960bca9f7 --- /dev/null +++ b/account_move_line_manufacture_info/tests/test_account_move_line_manufacture_info.py @@ -0,0 +1,174 @@ +# 2018 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +import odoo.tests.common as common +from odoo.tests import Form + + +class TestAccountMoveLineManufactureInfo(common.SavepointCase): + @classmethod + def setUpClass(cls): + super(TestAccountMoveLineManufactureInfo, cls).setUpClass() + + cls.product_obj = cls.env["product.product"] + cls.account_move_line_obj = cls.env["account.move.line"] + cls.bom_obj = cls.env["mrp.bom"] + cls.bom_line_obj = cls.env["mrp.bom.line"] + cls.production_obj = cls.env["mrp.production"] + cls.produce_wiz = cls.env["mrp.product.produce"] + cls.unbuild_obj = cls.env["mrp.unbuild"] + + cls.location_production = cls.env["stock.location"].search( + [("usage", "=", "production"), ("company_id", "=", cls.env.company.id)] + ) + + # Create accounts for WIP + cls.account_wip = cls.env["account.account"].create( + { + "name": "WIP", + "code": "999", + "user_type_id": cls.env.ref( + "account.data_account_type_current_assets" + ).id, + } + ) + + # Create categories + cls.categ_physical = cls.env.ref("product.product_category_5") + cls.categ_physical.write({"property_valuation": "real_time"}) + + # Assign WIP account to stock location production + cls.location_production.write( + { + "valuation_in_account_id": cls.account_wip.id, + "valuation_out_account_id": cls.account_wip.id, + } + ) + + # Create products: + cls.product_top = cls.product_obj.create( + { + "name": "Final Product", + "type": "product", + "categ_id": cls.categ_physical.id, + } + ) + cls.product_sub_1 = cls.product_obj.create( + { + "name": "L01-01", + "type": "product", + "standard_price": 100.0, + "categ_id": cls.categ_physical.id, + } + ) + cls.component_1 = cls.product_obj.create( + { + "name": "RM 01", + "type": "product", + "standard_price": 10.0, + "categ_id": cls.categ_physical.id, + } + ) + cls.component_2 = cls.product_obj.create( + { + "name": "RM 02", + "type": "product", + "standard_price": 15.0, + "categ_id": cls.categ_physical.id, + } + ) + cls.component_3 = cls.product_obj.create( + { + "name": "RM 03", + "type": "product", + "standard_price": 20.0, + "categ_id": cls.categ_physical.id, + } + ) + + # Create Bills of Materials: + cls.bom_top = cls.bom_obj.create( + {"product_tmpl_id": cls.product_top.product_tmpl_id.id} + ) + cls.line_top_1 = cls.bom_line_obj.create( + { + "product_id": cls.product_sub_1.id, + "bom_id": cls.bom_top.id, + "product_qty": 2.0, + } + ) + cls.line_top_2 = cls.bom_line_obj.create( + { + "product_id": cls.component_3.id, + "bom_id": cls.bom_top.id, + "product_qty": 3.0, + } + ) + + cls.bom_sub_1 = cls.bom_obj.create( + {"product_tmpl_id": cls.product_sub_1.product_tmpl_id.id} + ) + cls.line_sub_1_1 = cls.bom_line_obj.create( + { + "product_id": cls.component_1.id, + "bom_id": cls.bom_sub_1.id, + "product_qty": 4.0, + } + ) + cls.line_sub_1_2 = cls.bom_line_obj.create( + { + "product_id": cls.component_2.id, + "bom_id": cls.bom_sub_1.id, + "product_qty": 1.0, + } + ) + + def _produce(self, mo, qty=0.0): + wiz = Form( + self.produce_wiz.with_context({"active_id": mo.id, "active_ids": [mo.id]}) + ) + wiz.qty_producing = qty or mo.product_qty + produce_wizard = wiz.save() + produce_wizard.do_produce() + return True + + def _generate_mo(self, product_id, bom_id, qty=5.0): + mo_form = Form(self.production_obj) + mo_form.product_id = product_id + mo_form.bom_id = bom_id + mo_form.product_qty = qty + mo = mo_form.save() + mo.action_confirm() + return mo + + def test_01_manufacture_order(self): + """Create Manufacture Order and check account move lines created""" + self.product_top.write({"standard_price": 445.0}) + mo = self._generate_mo(self.product_top, self.bom_top) + + self._produce(mo, 5.0) + mo.button_mark_done() + account_move_lines = self.account_move_line_obj.search( + [("manufacture_order_id", "=", mo.id)] + ) + self.assertEqual(len(account_move_lines), 6) + + def test_02_ubuild_order(self): + """Create Unbuild Order and check account move lines created""" + self.product_top.write({"standard_price": 445.0}) + mo = self._generate_mo(self.product_top, self.bom_top) + + self._produce(mo, 3.0) + mo.button_mark_done() + + uo = Form(self.unbuild_obj) + uo.product_id = self.product_top + uo.bom_id = self.bom_top + uo.product_qty = 1 + uo.product_uom_id = self.product_top.uom_id + uo.save().action_unbuild() + + account_move_lines = self.account_move_line_obj.search( + [("unbuild_order_id", "=", uo.id)] + ) + self.assertEqual(len(account_move_lines), 6) diff --git a/account_move_line_manufacture_info/views/account_move_line_view.xml b/account_move_line_manufacture_info/views/account_move_line_view.xml new file mode 100644 index 000000000..d32891cf3 --- /dev/null +++ b/account_move_line_manufacture_info/views/account_move_line_view.xml @@ -0,0 +1,32 @@ + + + + + account.move.line.form + account.move.line + + + + + + + + + + + Account Moves + ir.actions.act_window + account.move.line + tree,form + [('manufacture_order_id', '=', active_id)] + + + + Account Moves + ir.actions.act_window + account.move.line + tree,form + [('unbuild_order_id', '=', active_id)] + + + diff --git a/account_move_line_manufacture_info/views/mrp_production_views.xml b/account_move_line_manufacture_info/views/mrp_production_views.xml new file mode 100644 index 000000000..253f0ddfb --- /dev/null +++ b/account_move_line_manufacture_info/views/mrp_production_views.xml @@ -0,0 +1,17 @@ + + + + + mrp.production.form + mrp.production + + + +