[FIX] adapt syntax for act_window lookup

This commit is contained in:
Florent Xicluna
2021-12-09 13:16:39 +01:00
committed by ArnauCForgeFlow
parent 6d20fa9f5f
commit 723621ec7a
2 changed files with 14 additions and 12 deletions

View File

@@ -99,14 +99,15 @@ class StockCycleCount(models.Model):
return True
def action_view_inventory(self):
action = self.env.ref("stock.action_inventory_form")
result = action.read()[0]
result["context"] = {}
action = self.env["ir.actions.act_window"]._for_xml_id(
"stock.action_inventory_form"
)
action["context"] = {}
adjustment_ids = self.mapped("stock_adjustment_ids").ids
if len(adjustment_ids) > 1:
result["domain"] = [("id", "in", adjustment_ids)]
action["domain"] = [("id", "in", adjustment_ids)]
elif len(adjustment_ids) == 1:
res = self.env.ref("stock.view_inventory_form", False)
result["views"] = [(res and res.id or False, "form")]
result["res_id"] = adjustment_ids and adjustment_ids[0] or False
return result
action["views"] = [(res and res.id or False, "form")]
action["res_id"] = adjustment_ids and adjustment_ids[0] or False
return action

View File

@@ -113,8 +113,9 @@ class StockLocation(models.Model):
def action_accuracy_stats(self):
self.ensure_one()
action = self.env.ref("stock_cycle_count.act_accuracy_stats")
result = action.read()[0]
new_domain = result["domain"][:-1] + ", ('location_ids', 'in', active_ids)]"
result["domain"] = new_domain
return result
action = self.env["ir.actions.act_window"]._for_xml_id(
"stock_cycle_count.act_accuracy_stats"
)
new_domain = action["domain"][:-1] + ", ('location_ids', 'in', active_ids)]"
action["domain"] = new_domain
return action