Skip to content

Commit

Permalink
[RFC] default_owner_id
Browse files Browse the repository at this point in the history
  • Loading branch information
RPSJR committed Nov 24, 2023
1 parent 6a999c0 commit 3a5752f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions fleet_vehicle_ownership/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ def action_view_vehicles(self):
self.ensure_one()
xmlid = "fleet.fleet_vehicle_action"
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
action["context"] = self.env.context.copy()
action["context"].update({"default_owner_id": self.id})
if self.vehicle_count > 1:
action["domain"] = [("id", "in", self.vehicle_ids.ids)]
else:
action["views"] = [
(self.env.ref("fleet.fleet_vehicle_view_form").id, "form")
]
action["res_id"] = self.vehicle_ids and self.vehicle_ids.ids[0] or False
if self.vehicle_count == 0:
action["context"] = self.env.context.copy()
action["context"].update({"default_owner_id": self.id})
return action

0 comments on commit 3a5752f

Please sign in to comment.