diff --git a/account_move_line_mrp_info/README.rst b/account_move_line_mrp_info/README.rst new file mode 100644 index 000000000..7d2b7c8d1 --- /dev/null +++ b/account_move_line_mrp_info/README.rst @@ -0,0 +1,83 @@ +============================ +Account Move Line Mrp Info +============================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/14.0/account_move_line_stock_info + :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-account_move_line_stock_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/153/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the manufacturing orders and unbuild orders to the account move lines that it generates. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +* The stock manager can check the journal items by accessing to 'Manufacturing > + Operations > Manufacturing Orders> Miscellaneous page'. + +* A user belonging to the group 'Show Full Accounting Features' can review the + details of a move that is associated to a journal item through + 'Invoicing > Accounting > Journal Entries (or Journal items)'. + +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 +~~~~~~~~~~~~ + +* Nuria Xifre Martin + +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_mrp_info/__init__.py b/account_move_line_mrp_info/__init__.py new file mode 100644 index 000000000..01aac13a6 --- /dev/null +++ b/account_move_line_mrp_info/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models +from .hooks import pre_init_hook diff --git a/account_move_line_mrp_info/__manifest__.py b/account_move_line_mrp_info/__manifest__.py new file mode 100644 index 000000000..e09e0b590 --- /dev/null +++ b/account_move_line_mrp_info/__manifest__.py @@ -0,0 +1,18 @@ +# © 2022ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Account Move Line Mrp Info", + "version": "14.0.1.0.0", + "author": "ForgeFlow," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/manufacture", + "category": "Manufacture", + "depends": ["account_move_line_stock_info", "mrp"], + "installable": True, + "pre_init_hook": "pre_init_hook", + "license": "AGPL-3", + "data": [ + "security/ir.model.access.csv", + "views/account_move_line_view.xml", + "views/mrp_production_view.xml", + ], +} diff --git a/account_move_line_mrp_info/hooks.py b/account_move_line_mrp_info/hooks.py new file mode 100644 index 000000000..bcb4d1f15 --- /dev/null +++ b/account_move_line_mrp_info/hooks.py @@ -0,0 +1,51 @@ +import logging + +from psycopg2 import sql + + +def pre_init_hook(cr): + """Precreate move_type and fill with appropriate values to prevent + a MemoryError when the ORM attempts to call its compute method on a large + amount of preexisting moves. Note that the order of the mapping is + important as one move can have move lines on accounts of multiple types + and the move type is set in the order of precedence.""" + logger = logging.getLogger(__name__) + logger.info("Add mrp_info") + cr.execute( + "ALTER TABLE account_move_line ADD COLUMN IF NOT EXISTS mrp_production_id INTEGER" + ) + query = sql.SQL( + """ + with q2 as ( + select aml.id as account_move_id, + coalesce(sm.production_id,sm.raw_material_production_id) as mrp_id + from account_move_line aml + inner join stock_move sm + on sm.id=aml.stock_move_id + where coalesce(sm.production_id,sm.raw_material_production_id) is not null) + update account_move_line + set mrp_production_id = q2.mrp_id + from q2 + where q2.account_move_id=account_move_line.id; + """ + ) + cr.execute(query) + cr.execute( + "ALTER TABLE account_move_line ADD COLUMN IF NOT EXISTS unbuild_id INTEGER" + ) + query = sql.SQL( + """ + with q2 as ( + select aml.id as account_move_id, + sm.unbuild_id as unb_id + from account_move_line aml + inner join stock_move sm + on sm.id=aml.stock_move_id + where sm.unbuild_id is not null) + update account_move_line + set unbuild_id = q2.unb_id + from q2 + where q2.account_move_id=account_move_line.id; + """ + ) + cr.execute(query) diff --git a/account_move_line_mrp_info/models/__init__.py b/account_move_line_mrp_info/models/__init__.py new file mode 100644 index 000000000..1865fc612 --- /dev/null +++ b/account_move_line_mrp_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 mrp_production diff --git a/account_move_line_mrp_info/models/account_move_line.py b/account_move_line_mrp_info/models/account_move_line.py new file mode 100644 index 000000000..6406cb67c --- /dev/null +++ b/account_move_line_mrp_info/models/account_move_line.py @@ -0,0 +1,39 @@ +# Copyright 2019 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + mrp_production_id = fields.Many2one( + comodel_name="mrp.production", + string="Manufacturing Order", + compute="_compute_mrp_production", + store=True, + ) + unbuild_id = fields.Many2one( + comodel_name="mrp.unbuild", + string="Unbuild Order", + compute="_compute_mrp_unbuild", + store=True, + ) + + @api.depends("stock_move_id") + def _compute_mrp_production(self): + for rec in self: + if rec.stock_move_id.production_id: + rec.mrp_production_id = rec.stock_move_id.production_id.id + elif rec.stock_move_id.raw_material_production_id: + rec.mrp_production_id = rec.stock_move_id.raw_material_production_id.id + else: + rec.mrp_production_id = False + + @api.depends("stock_move_id") + def _compute_mrp_unbuild(self): + for rec in self: + if rec.stock_move_id.unbuild_id: + rec.unbuild_id = rec.stock_move_id.unbuild_id.id + else: + rec.unbuild_id = False diff --git a/account_move_line_mrp_info/models/mrp_production.py b/account_move_line_mrp_info/models/mrp_production.py new file mode 100644 index 000000000..b7943a75f --- /dev/null +++ b/account_move_line_mrp_info/models/mrp_production.py @@ -0,0 +1,20 @@ +# Copyright 2019 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class MrpProduction(models.Model): + _inherit = "mrp.production" + + account_move_line_ids = fields.One2many( + comodel_name="account.move.line", inverse_name="mrp_production_id", copy=False + ) + + +class MrpUnbuild(models.Model): + _inherit = "mrp.unbuild" + + account_move_line_ids = fields.One2many( + comodel_name="account.move.line", inverse_name="unbuild_id", copy=False + ) diff --git a/account_move_line_mrp_info/readme/CONTRIBUTORS.rst b/account_move_line_mrp_info/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..3eeb31a71 --- /dev/null +++ b/account_move_line_mrp_info/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Nuria Xifre Martin diff --git a/account_move_line_mrp_info/readme/DESCRIPTION.rst b/account_move_line_mrp_info/readme/DESCRIPTION.rst new file mode 100644 index 000000000..ae70eee65 --- /dev/null +++ b/account_move_line_mrp_info/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds the manufacturing orders and unbuild orders to the account move lines that it generates. diff --git a/account_move_line_mrp_info/readme/USAGE.rst b/account_move_line_mrp_info/readme/USAGE.rst new file mode 100644 index 000000000..4a18f3d3d --- /dev/null +++ b/account_move_line_mrp_info/readme/USAGE.rst @@ -0,0 +1,6 @@ +* The stock manager can check the journal items by accessing to 'Manufacturing > + Operations > Manufacturing Orders> Miscellaneous page'. + +* A user belonging to the group 'Show Full Accounting Features' can review the + details of a move that is associated to a journal item through + 'Invoicing > Accounting > Journal Entries (or Journal items)'. diff --git a/account_move_line_mrp_info/security/ir.model.access.csv b/account_move_line_mrp_info/security/ir.model.access.csv new file mode 100644 index 000000000..32b1ebde7 --- /dev/null +++ b/account_move_line_mrp_info/security/ir.model.access.csv @@ -0,0 +1,5 @@ +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,stock.group_stock_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 diff --git a/account_move_line_mrp_info/static/description/icon.png b/account_move_line_mrp_info/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_move_line_mrp_info/static/description/icon.png differ diff --git a/account_move_line_mrp_info/static/description/index.html b/account_move_line_mrp_info/static/description/index.html new file mode 100644 index 000000000..f950692f9 --- /dev/null +++ b/account_move_line_mrp_info/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +Account Move Line Mrp Info + + + +
+

Account Move Line Stock Info

+ + +

Beta License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runbot

+

This module adds the stock move to the account move lines that it generates.

+

Table of contents

+ +
+

Usage

+
    +
  • The stock manager can check the journal items by accessing to ‘Inventory > +Reports > Stock moves’.
  • +
  • A user belonging to the group ‘Show Full Accounting Features’ can review the +details of a move that is associated to a journal item through +‘Invoicing > Accounting > Journal Entries (or Journal items)’.
  • +
+
+
+

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

+ +
+
+

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/stock-logistics-warehouse 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_mrp_info/views/account_move_line_view.xml b/account_move_line_mrp_info/views/account_move_line_view.xml new file mode 100644 index 000000000..44d690cd2 --- /dev/null +++ b/account_move_line_mrp_info/views/account_move_line_view.xml @@ -0,0 +1,15 @@ + + + + account.move.line.form + account.move.line + + + + + + + + + + diff --git a/account_move_line_mrp_info/views/mrp_production_view.xml b/account_move_line_mrp_info/views/mrp_production_view.xml new file mode 100644 index 000000000..623482a0f --- /dev/null +++ b/account_move_line_mrp_info/views/mrp_production_view.xml @@ -0,0 +1,24 @@ + + + + mrp.production + + + + + + + + + + + + mrp.unbuild + + + + + + + + diff --git a/setup/account_move_line_mrp_info/odoo/addons/account_move_line_mrp_info b/setup/account_move_line_mrp_info/odoo/addons/account_move_line_mrp_info new file mode 120000 index 000000000..7f4d7b4a5 --- /dev/null +++ b/setup/account_move_line_mrp_info/odoo/addons/account_move_line_mrp_info @@ -0,0 +1 @@ +../../../../account_move_line_mrp_info \ No newline at end of file diff --git a/setup/account_move_line_mrp_info/setup.py b/setup/account_move_line_mrp_info/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/account_move_line_mrp_info/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)