[IMP] stock_request_mrp: Add _get_stock_requests() method to get all stock requests from action.

Allows inheritance by other modules

TT43297
This commit is contained in:
Víctor Martínez
2023-08-28 10:18:22 +02:00
parent d8a5d4c578
commit b5b9c6bf5f

View File

@@ -23,6 +23,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
@@ -30,8 +34,8 @@ 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: