Skip to content

Commit

Permalink
[MIG] fleet_vehicle_history_date_end: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Dec 31, 2024
1 parent bcf40d2 commit 989ffc8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion fleet_vehicle_history_date_end/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"development_status": "Production/Stable",
"website": "https://github.com/OCA/fleet",
"license": "AGPL-3",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"depends": ["fleet"],
"data": [],
"installable": True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
class FleetVehicleAssignationLog(models.Model):
_inherit = "fleet.vehicle.assignation.log"

@api.model
def create(self, vals):
res = super().create(vals)
history = self.search(
[
("vehicle_id", "=", res.vehicle_id.id),
("date_end", "=", False),
("id", "!=", res.id),
]
)
if history:
history.write({"date_end": res.date_start})
@api.model_create_multi
def create(self, vals_list):
res = super().create(vals_list)

for res_item in res:
history = self.search(
[
("vehicle_id", "=", res_item.vehicle_id.id),
("date_end", "=", False),
("id", "!=", res_item.id),
]
)
if history:
history.write({"date_end": res_item.date_start})

return res

0 comments on commit 989ffc8

Please sign in to comment.