Skip to content

Commit

Permalink
[FIX] stock_picking_create_repair: new way to access actions
Browse files Browse the repository at this point in the history
  • Loading branch information
oihane committed Jan 13, 2025
1 parent 21fc072 commit b96d58e
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions stock_picking_create_repair/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@
class PurchaseOrder(models.Model):
_inherit = "purchase.order"

is_repair = fields.Boolean(string="It's repair", default=False, copy=False)
is_repair = fields.Boolean(
string="It's repair",
default=False,
copy=False,
)
repair_ids = fields.One2many(
string="Repairs",
comodel_name="repair.order",
inverse_name="purchase_order_id",
copy=False,
)
repairs_count = fields.Integer(
string="# Repairs", compute="_compute_repairs_count", copy=False, store=True
string="# Repairs",
compute="_compute_repairs_count",
copy=False,
store=True,
)

@api.depends("repair_ids")
Expand All @@ -26,16 +33,16 @@ def _compute_repairs_count(self):

def action_repairs_from_purchase(self):
self.ensure_one()
action = self.env.ref("repair.action_repair_order_tree")
action_dict = action.read()[0] if action else {}
domain = expression.AND(
action = self.env["ir.actions.actions"]._for_xml_id(
"repair.action_repair_order_tree"
)
action["domain"] = expression.AND(
[
[("id", "in", self.repair_ids.ids)],
safe_eval(action.domain or "[]"),
safe_eval(action.get("domain") or "[]"),
]
)
action_dict.update({"domain": domain})
return action_dict
return action

def _prepare_picking(self):
vals = super()._prepare_picking()
Expand Down

0 comments on commit b96d58e

Please sign in to comment.