diff --git a/account_move_line_manufacture_info/README.rst b/account_move_line_manufacture_info/README.rst new file mode 100644 index 000000000..dddb7c959 --- /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/11.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-11-0/manufacture-11-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/11.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 +~~~~~~~ + +* Eficent + +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..0c0149451 --- /dev/null +++ b/account_move_line_manufacture_info/__manifest__.py @@ -0,0 +1,22 @@ +# © 2019 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Account Move Line Manufacture Information", + "version": "11.0.1.0.0", + "depends": [ + "stock_account", + "mrp" + ], + "author": "Eficent," + "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/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..105e7e92f --- /dev/null +++ b/account_move_line_manufacture_info/models/account_move_line.py @@ -0,0 +1,16 @@ +# © 2019 Eficent Business and IT Consulting Services 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..dda4dbe84 --- /dev/null +++ b/account_move_line_manufacture_info/models/stock_move.py @@ -0,0 +1,25 @@ +# © 2019 Eficent Business and IT Consulting Services 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): + res = super(StockMove, self)._prepare_account_move_line( + qty, cost, credit_account_id, debit_account_id) + 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 + 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..dcd1839c8 --- /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..34a2d4d00 --- /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. \ No newline at end of file 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..9220760ae --- /dev/null +++ b/account_move_line_manufacture_info/static/description/index.html @@ -0,0 +1,408 @@ + + + + + + +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

+
    +
  • Eficent
  • +
+
+
+

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/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..a7e14ac28 --- /dev/null +++ b/account_move_line_manufacture_info/tests/test_account_move_line_manufacture_info.py @@ -0,0 +1,156 @@ +# 2018 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +import odoo.tests.common as common + + +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.location_production = cls.env.ref('stock.location_production') + cls.production_obj = cls.env['mrp.production'] + cls.produce_wiz = cls.env['mrp.product.produce'] + cls.unbuild_obj = cls.env['mrp.unbuild'] + + # 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 01', + '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 = self.produce_wiz.with_context({ + 'active_id': mo.id, + 'active_ids': [mo.id], + }).create({ + 'product_qty': qty or mo.product_qty, + }) + wiz.do_produce() + return True + + 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.production_obj.create({ + 'name': 'MO-01', + 'product_id': self.product_top.id, + 'product_uom_id': self.product_top.uom_id.id, + 'product_qty': 5.0, + 'bom_id': self.bom_top.id, + }) + mo.action_assign() + 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.production_obj.create({ + 'name': 'MO-01', + 'product_id': self.product_top.id, + 'product_uom_id': self.product_top.uom_id.id, + 'product_qty': 5.0, + 'bom_id': self.bom_top.id, + }) + mo.action_assign() + self._produce(mo, 3.0) + mo.button_mark_done() + uo = self.unbuild_obj.create({ + 'product_id': self.product_top.id, + 'bom_id': self.bom_top.id, + 'product_qty': 1.0, + 'product_uom_id': self.product_top.uom_id.id, + }) + uo.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..b9f71d26c --- /dev/null +++ b/account_move_line_manufacture_info/views/account_move_line_view.xml @@ -0,0 +1,34 @@ + + + + + account.move.line.form + account.move.line + + + + + + + + + + + Account Moves + ir.actions.act_window + account.move.line + form + tree,form + [('manufacture_order_id', '=', active_id)] + + + + Account Moves + ir.actions.act_window + account.move.line + form + 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..fd19f6bbd --- /dev/null +++ b/account_move_line_manufacture_info/views/mrp_production_views.xml @@ -0,0 +1,19 @@ + + + + + + mrp.production.form + mrp.production + + + +