From a2456abda3c4f5412eca7e863258df6ed2fb0fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Mon, 28 Aug 2023 10:25:47 +0200 Subject: [PATCH] [IMP] stock_request_purchase: Add _get_stock_requests() method to get all stock requests from action. Allows inheritance by other modules TT43297 --- stock_request_purchase/models/purchase_order.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stock_request_purchase/models/purchase_order.py b/stock_request_purchase/models/purchase_order.py index 047fcc47c..9c42c2dc6 100644 --- a/stock_request_purchase/models/purchase_order.py +++ b/stock_request_purchase/models/purchase_order.py @@ -22,6 +22,10 @@ class PurchaseOrder(models.Model): rec.stock_request_ids = rec.order_line.mapped("stock_request_ids") 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 @@ -30,7 +34,7 @@ class PurchaseOrder(models.Model): "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: