diff --git a/mrp_usability/__manifest__.py b/mrp_usability/__manifest__.py index 54e877f..19876ed 100644 --- a/mrp_usability/__manifest__.py +++ b/mrp_usability/__manifest__.py @@ -1,11 +1,10 @@ -# © 2015-2016 Akretion (http://www.akretion.com) +# Copyright 2015-2020 Akretion (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - { 'name': 'MRP Usability', - 'version': '12.0.1.0.0', + 'version': '14.0.1.0.0', 'category': 'Manufacturing', 'license': 'AGPL-3', 'summary': 'Usability improvements on manufacturing', @@ -13,9 +12,9 @@ 'website': 'http://www.akretion.com', 'depends': ['mrp'], 'data': [ - 'views/mrp_views.xml', - 'views/product_views.xml', - 'report/mrp_report.xml' + 'views/mrp_production.xml', + 'views/product_template.xml', + # 'report/mrp_report.xml' # TODO ], - 'installable': False, + 'installable': True, } diff --git a/mrp_usability/models/__init__.py b/mrp_usability/models/__init__.py index 820357d..4668879 100644 --- a/mrp_usability/models/__init__.py +++ b/mrp_usability/models/__init__.py @@ -1,2 +1,2 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from . import mrp, product +from . import mrp_production +from . import product diff --git a/mrp_usability/models/mrp.py b/mrp_usability/models/mrp_production.py similarity index 81% rename from mrp_usability/models/mrp.py rename to mrp_usability/models/mrp_production.py index 935e2d8..a69799a 100644 --- a/mrp_usability/models/mrp.py +++ b/mrp_usability/models/mrp_production.py @@ -1,4 +1,4 @@ -# © 2015-2016 Akretion (http://www.akretion.com) +# Copyright 2015-2020 Akretion (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -8,8 +8,8 @@ from odoo import api, models class MrpProduction(models.Model): _inherit = 'mrp.production' - _order = 'id desc' + # Method used by the report, inherited in this module @api.model def get_stock_move_sold_out_report(self, move): lines = move.active_move_line_ids diff --git a/mrp_usability/models/product.py b/mrp_usability/models/product.py index 12fba4c..5073b9b 100644 --- a/mrp_usability/models/product.py +++ b/mrp_usability/models/product.py @@ -11,34 +11,30 @@ class ProductTemplate(models.Model): """Replace native action `template_open_bom` to distinguish if we will display only one BoM form or a list of BoMs.""" self.ensure_one() - - act_window_xml_id = "mrp.mrp_bom_form_action" - act_window = self.env.ref(act_window_xml_id).read()[0] - if self.bom_count > 1: - act_window["context"] = { - "default_product_tmpl_id": self.id, - "search_default_product_tmpl_id": self.id, - } + if self.bom_count == 1: + action = self.env.ref("mrp.mrp_bom_form_action").read()[0] + bom = self.env["mrp.bom"].search([("product_tmpl_id", "=", self.id)]) + action.update({ + "context": {"default_product_tmpl_id": self.id}, + "views": False, + "view_mode": "form,tree", + "res_id": bom.id, + }) else: - act_window["context"] = {"default_product_tmpl_id": self.id} - act_window["views"] = [(self.env.ref("mrp.mrp_bom_form_view").id, "form")] - act_window["res_id"] = ( - self.env["mrp.bom"].search([("product_tmpl_id", "=", self.id)]).id - ) - - return act_window + action = self.env.ref("mrp.template_open_bom").read()[0] + return action class ProductProduct(models.Model): _inherit = "product.product" def action_view_bom(self): - res = super().action_view_bom() - - bom_target_ids = self.env["mrp.bom"].search(res["domain"]) - + action = super().action_view_bom() + bom_target_ids = self.env["mrp.bom"].search(action["domain"]) if len(bom_target_ids) == 1: - res["views"] = [(self.env.ref("mrp.mrp_bom_form_view").id, "form")] - res["res_id"] = bom_target_ids[0].id - - return res + action.update({ + "views": False, + "view_mode": "form,tree", + "res_id": bom_target_ids[0].id, + }) + return action diff --git a/mrp_usability/views/mrp_production.xml b/mrp_usability/views/mrp_production.xml new file mode 100644 index 0000000..7c8cdc5 --- /dev/null +++ b/mrp_usability/views/mrp_production.xml @@ -0,0 +1,32 @@ + + + + + + + + usability.mrp.production.form + mrp.production + + + + + + + + + + + + + + + + + diff --git a/mrp_usability/views/mrp_views.xml b/mrp_usability/views/mrp_views.xml deleted file mode 100644 index ba5c5c1..0000000 --- a/mrp_usability/views/mrp_views.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - usability.mrp.production.form - mrp.production - - - - - - - - - - - - - - - - - - stock.move - - - - - - - - - - - mrp.bom - - - - - - - - - - mrp.bom - - - - - - - - - diff --git a/mrp_usability/views/product_template.xml b/mrp_usability/views/product_template.xml new file mode 100644 index 0000000..8258b88 --- /dev/null +++ b/mrp_usability/views/product_template.xml @@ -0,0 +1,16 @@ + + + + + product.template.procurement + product.template + + + + object + action_view_bom + + + + + diff --git a/mrp_usability/views/product_views.xml b/mrp_usability/views/product_views.xml deleted file mode 100644 index 0d2da11..0000000 --- a/mrp_usability/views/product_views.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - product.template.procurement - product.template - - - - - 1 - - - - - - - - - diff --git a/mrp_usability/views/stock_move.xml b/mrp_usability/views/stock_move.xml new file mode 100644 index 0000000..560f058 --- /dev/null +++ b/mrp_usability/views/stock_move.xml @@ -0,0 +1,21 @@ + + + + + + + stock.move + + + + + + + + + +