Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] repair_order_type: Add api.depends to api.onchange #99

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion repair_order_type/models/repair_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class RepairLine(models.Model):
_inherit = "repair.line"

@api.onchange("type", "repair_id", "repair_id.type_id")
@api.onchange("type", "repair_id")
def onchange_operation_type(self):
res = super().onchange_operation_type()
if self.type == "add":
Expand All @@ -16,3 +16,14 @@ def onchange_operation_type(self):
self.location_id = self.repair_id.type_id.location_dest_id.id
self.location_dest_id = self.repair_id.type_id.location_id.id
return res

@api.depends("repair_id.type_id")
def _compute_location_id(self):
res = super()._compute_location_id()
if self.type == "add":
self.location_id = self.repair_id.type_id.location_id.id
self.location_dest_id = self.repair_id.type_id.location_dest_id.id
else:
self.location_id = self.repair_id.type_id.location_dest_id.id
self.location_dest_id = self.repair_id.type_id.location_id.id
return res
Comment on lines +20 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No estas teniendo en cuenta que el compute se ejecuta de forma múltiple, y debe de modificarse también en el caso de que se cambie el type

Loading