From 17f99538d4d8f2bbc64263d0bb81917f80c87868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Mon, 28 Aug 2023 10:14:42 +0200 Subject: [PATCH 1/2] [IMP] stock_request_mrp: Change invisible attr of the action action_view_stock_request action of mrp.production TT43297 --- stock_request_mrp/views/mrp_production_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock_request_mrp/views/mrp_production_views.xml b/stock_request_mrp/views/mrp_production_views.xml index 879c86062..d0094b7a8 100644 --- a/stock_request_mrp/views/mrp_production_views.xml +++ b/stock_request_mrp/views/mrp_production_views.xml @@ -17,7 +17,7 @@ name="action_view_stock_request" class="oe_stat_button" icon="fa-chain" - attrs="{'invisible':[('stock_request_ids', '=', [])]}" + attrs="{'invisible':[('stock_request_count', '=', 0)]}" > Date: Mon, 28 Aug 2023 10:18:22 +0200 Subject: [PATCH 2/2] [IMP] stock_request_mrp: Add _get_stock_requests() method to get all stock requests from action. Allows inheritance by other modules TT43297 --- stock_request_mrp/models/mrp_production.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stock_request_mrp/models/mrp_production.py b/stock_request_mrp/models/mrp_production.py index 30756b621..25e2be2e3 100644 --- a/stock_request_mrp/models/mrp_production.py +++ b/stock_request_mrp/models/mrp_production.py @@ -24,6 +24,10 @@ class MrpProduction(models.Model): for rec in self: rec.stock_request_count = len(rec.stock_request_ids) + def _get_stock_requests(self): + """Get all stock requests from action (allows inheritance by other modules).""" + return self.mapped("stock_request_ids") + def action_view_stock_request(self): """ :return dict: dictionary value for created view @@ -31,7 +35,7 @@ class MrpProduction(models.Model): action = self.env["ir.actions.act_window"]._for_xml_id( "stock_request.action_stock_request_form" ) - requests = self.mapped("stock_request_ids") + requests = self._get_stock_requests() if len(requests) > 1: action["domain"] = [("id", "in", requests.ids)] elif requests: