diff --git a/mrp_bom_component_find/README.rst b/mrp_bom_component_find/README.rst new file mode 100644 index 000000000..dd1f1cc4d --- /dev/null +++ b/mrp_bom_component_find/README.rst @@ -0,0 +1,74 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +====================== +MRP BOM Component Find +====================== + +This module add MRP BOM component find functionality (Use Case). + +Allows you to find the product usages across all Bill of Materials. + + +Usage +===== + +* From the form of a component click on the button 'Component find'. +* or click on the 'Master Data / Component find' and choose a component. +* The result displays the list of finished products containing this + component and in which level of the bom this component appears + + +.. image:: static/description/mrp_bom_component_find.png + :alt: Sample Component find + :width: 95 % + :align: center + + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/129/10.0 + + +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 smash it by providing detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Tony Galmiche (http://infosaone.com) + +Do not contact contributors directly about support or help with technical issues. + + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. + + + diff --git a/mrp_bom_component_find/__init__.py b/mrp_bom_component_find/__init__.py new file mode 100644 index 000000000..35e7c9600 --- /dev/null +++ b/mrp_bom_component_find/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import models +from . import wizard diff --git a/mrp_bom_component_find/__manifest__.py b/mrp_bom_component_find/__manifest__.py new file mode 100644 index 000000000..0c2b59e74 --- /dev/null +++ b/mrp_bom_component_find/__manifest__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Tony Galmiche - InfoSaône +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'MRB BOM Component Find (Product Use Case)', + 'version': '10.0.1.0.0', + 'category': 'mrp', + 'summary': 'Know the case of multi-level use of a component from bom', + 'author': 'Tony Galmiche,' + 'Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/manufacture', + 'license': 'AGPL-3', + 'depends': [ + 'mrp', + ], + 'data': [ + 'views/product_views.xml', + 'wizard/mrp_bom_component_find_wizard.xml', + ], + 'update_xml': [], + 'demo_xml': [], + 'installable': True, + 'application': False, +} diff --git a/mrp_bom_component_find/i18n/fr.po b/mrp_bom_component_find/i18n/fr.po new file mode 100644 index 000000000..198dc2294 --- /dev/null +++ b/mrp_bom_component_find/i18n/fr.po @@ -0,0 +1,130 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_bom_component_find +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-23 07:49+0000\n" +"PO-Revision-Date: 2018-04-23 07:49+0000\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_bom_component_find +#: model:ir.ui.view,arch_db:mrp_bom_component_find.mrp_bom_component_find_wizard_form +msgid "Cancel" +msgstr "Annuler" + +#. module: mrp_bom_component_find +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_line_component_id +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_wizard_product_id +msgid "Component" +msgstr "Composant" + +#. module: mrp_bom_component_find +#: model:ir.actions.act_window,name:mrp_bom_component_find.mrp_bom_component_find_wizard_action +#: model:ir.ui.menu,name:mrp_bom_component_find.mrp_bom_component_find_menu +#: model:ir.ui.view,arch_db:mrp_bom_component_find.mrp_bom_component_find_wizard_form +#: model:ir.ui.view,arch_db:mrp_bom_component_find.product_product_form_view_use_case_button +#: model:ir.ui.view,arch_db:mrp_bom_component_find.product_template_form_view_use_case_button +msgid "Component find" +msgstr "Recherche composant" + +#. module: mrp_bom_component_find +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_line_create_uid +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_wizard_create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: mrp_bom_component_find +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_line_create_date +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_wizard_create_date +msgid "Created on" +msgstr "Créé le" + +#. module: mrp_bom_component_find +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_line_display_name +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_wizard_display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: mrp_bom_component_find +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_line_id +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_wizard_id +msgid "ID" +msgstr "ID" + +#. module: mrp_bom_component_find +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_line___last_update +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_wizard___last_update +msgid "Last Modified on" +msgstr "Dernière Modification le" + +#. module: mrp_bom_component_find +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_line_write_uid +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_wizard_write_uid +msgid "Last Updated by" +msgstr "Dernière mise à jour par" + +#. module: mrp_bom_component_find +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_line_write_date +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_wizard_write_date +msgid "Last Updated on" +msgstr "Dernière mise à jour le" + +#. module: mrp_bom_component_find +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_line_level +msgid "Level" +msgstr "Niveau" + +#. module: mrp_bom_component_find +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_line_line +msgid "Line" +msgstr "Ligne" + +#. module: mrp_bom_component_find +#: model:ir.ui.view,arch_db:mrp_bom_component_find.mrp_bom_component_find_wizard_form +msgid "OK" +msgstr "OK" + +#. module: mrp_bom_component_find +#: model:ir.model,name:mrp_bom_component_find.model_product_product +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_line_mrp_bom_id +msgid "Product" +msgstr "Article" + +#. module: mrp_bom_component_find +#: model:ir.model,name:mrp_bom_component_find.model_product_template +msgid "Product Template" +msgstr "Modèle d'article" + +#. module: mrp_bom_component_find +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_line_quantity +msgid "Quantity" +msgstr "Quantité" + +#. module: mrp_bom_component_find +#: model:ir.model.fields,field_description:mrp_bom_component_find.field_mrp_bom_component_find_line_wizard_id +msgid "Wizard" +msgstr "Assistant" + +#. module: mrp_bom_component_find +#: model:ir.model,name:mrp_bom_component_find.model_mrp_bom_component_find_line +msgid "mrp.bom.component.find.line" +msgstr "mrp.bom.component.find.line" + +#. module: mrp_bom_component_find +#: model:ir.model,name:mrp_bom_component_find.model_mrp_bom_component_find_wizard +msgid "mrp.bom.component.find.wizard" +msgstr "mrp.bom.component.find.wizard" + +#. module: mrp_bom_component_find +#: model:ir.ui.view,arch_db:mrp_bom_component_find.mrp_bom_component_find_wizard_form +msgid "or" +msgstr "ou" + diff --git a/mrp_bom_component_find/models/__init__.py b/mrp_bom_component_find/models/__init__.py new file mode 100644 index 000000000..d7d73083c --- /dev/null +++ b/mrp_bom_component_find/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import product diff --git a/mrp_bom_component_find/models/product.py b/mrp_bom_component_find/models/product.py new file mode 100644 index 000000000..41a331a67 --- /dev/null +++ b/mrp_bom_component_find/models/product.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + @api.multi + def use_case_action(self): + for obj in self: + products = self.env['product.product'].search([ + ('product_tmpl_id', '=', obj.id) + ]) + for product in products: + return product.use_case_action() + + +class ProductProduct(models.Model): + _inherit = "product.product" + + @api.multi + def use_case_action(self): + for obj in self: + vals = { + 'product_id': obj.id + } + wizard = self.env['mrp.bom.component.find.wizard'].create(vals) + return wizard.do_search_component() diff --git a/mrp_bom_component_find/static/description/icon.png b/mrp_bom_component_find/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mrp_bom_component_find/static/description/icon.png differ diff --git a/mrp_bom_component_find/static/description/mrp_bom_component_find.png b/mrp_bom_component_find/static/description/mrp_bom_component_find.png new file mode 100644 index 000000000..36b64e4d6 Binary files /dev/null and b/mrp_bom_component_find/static/description/mrp_bom_component_find.png differ diff --git a/mrp_bom_component_find/views/product_views.xml b/mrp_bom_component_find/views/product_views.xml new file mode 100644 index 000000000..ad2b3cc6d --- /dev/null +++ b/mrp_bom_component_find/views/product_views.xml @@ -0,0 +1,31 @@ + + + + + product.template.procurement + product.template + + + +
+ +
+
+
+ + product.product.procurement + product.product + + + +
+ +
+
+
+
+
diff --git a/mrp_bom_component_find/wizard/__init__.py b/mrp_bom_component_find/wizard/__init__.py new file mode 100644 index 000000000..aba89293f --- /dev/null +++ b/mrp_bom_component_find/wizard/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import mrp_bom_component_find_wizard diff --git a/mrp_bom_component_find/wizard/mrp_bom_component_find_wizard.py b/mrp_bom_component_find/wizard/mrp_bom_component_find_wizard.py new file mode 100644 index 000000000..206696715 --- /dev/null +++ b/mrp_bom_component_find/wizard/mrp_bom_component_find_wizard.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api +from odoo.addons import decimal_precision as dp + + +class MrpBomComponentFindWizard(models.TransientModel): + _name = 'mrp.bom.component.find.wizard' + + product_id = fields.Many2one('product.product', 'Component', required=True) + + @api.multi + def mrp_bom_component_find(self, wizard_id, component_id, level): + cr = self._cr + cr.execute(""" + select + mbl.sequence, + mbl.product_id, + mbl.product_qty, + mb.product_tmpl_id, + mb.id mb_id, + (select id from product_product + where product_tmpl_id=mb.product_tmpl_id limit 1) compose_id + from mrp_bom_line mbl inner join mrp_bom mb on mbl.bom_id=mb.id + where mbl.product_id=%s + """, (str(component_id),)) + result = cr.fetchall() + for row in result: + compose_id = row[5] + level_txt = '' + for i in range(1, level): + level_txt = level_txt + u'-' + level_txt = level_txt + str(level) + vals = { + 'wizard_id': wizard_id, + 'level': level_txt, + 'component_id': component_id, + 'line': row[0], + 'quantity': row[2], + 'mrp_bom_id': row[4], + } + self.env['mrp.bom.component.find.line'].create(vals) + self.mrp_bom_component_find(wizard_id, compose_id, level + 1) + + @api.multi + def do_search_component(self): + for obj in self: + if obj.product_id: + self.mrp_bom_component_find(obj.id, obj.product_id.id, 1) + return { + 'name': "Component find %s " % obj.product_id.name, + 'view_mode': 'tree,form', + 'view_type': 'form', + 'res_model': 'mrp.bom.component.find.line', + 'type': 'ir.actions.act_window', + 'domain': [('wizard_id', '=', obj.id)], + } + + +class MrpBomComponentFindLine(models.TransientModel): + _name = 'mrp.bom.component.find.line' + + wizard_id = fields.Many2one('mrp.bom.component.find.wizard', 'Wizard') + level = fields.Char('Level') + component_id = fields.Many2one('product.product', 'Component') + line = fields.Integer('Line') + quantity = fields.Float( + 'Quantity', digits=dp.get_precision('Product Unit of Measure')) + mrp_bom_id = fields.Many2one('mrp.bom', 'Product') diff --git a/mrp_bom_component_find/wizard/mrp_bom_component_find_wizard.xml b/mrp_bom_component_find/wizard/mrp_bom_component_find_wizard.xml new file mode 100644 index 000000000..5ea9f626b --- /dev/null +++ b/mrp_bom_component_find/wizard/mrp_bom_component_find_wizard.xml @@ -0,0 +1,79 @@ + + + + mrp.bom.component.find.wizard.form + mrp.bom.component.find.wizard + +
+ + + +
+
+
+
+
+ + Component find + ir.actions.act_window + mrp.bom.component.find.wizard + form + tree,form + + new + + + mrp_bom_component_find_line_form_view + mrp.bom.component.find.line + +
+ + + + + + + + + +
+
+
+ + mrp_bom_component_find_line_tree_view + mrp.bom.component.find.line + tree + + + + + + + + + + + + mrp_bom_component_find_line_search_view + mrp.bom.component.find.line + + + + + + + + + + +
diff --git a/mrp_mto_with_stock/README.rst b/mrp_mto_with_stock/README.rst index fa154d0f2..8ddb7bd7b 100644 --- a/mrp_mto_with_stock/README.rst +++ b/mrp_mto_with_stock/README.rst @@ -29,9 +29,10 @@ To configure this module, you need to: standard behavior. If you want to use the second mode, based on forecast quantity + #. Go to the warehouse you want to follow this behaviour. -#. In the view form go to the tab *Warehouse Configuration* and set the - *MRP MTO with forecast stock*. You still need to configure the products +#. In the view form go to the tab *Warehouse Configuration* and set the *MRP + MTO with forecast stock*. You still need to configure the products like described in last step. Usage