Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 41a7b422b72c13e0efd01d696e07e118289ef9a6
Author: Antonio Rivera <arivera@opensourceintegrators.com>
Date:   Mon Jul 3 13:40:56 2023 -0600

    [FIX] fieldservice_stage_server_action

commit 2354f29486629e5cca2742ad120fa00ebda58ac5
Author: Antonio Rivera <arivera@opensourceintegrators.com>
Date:   Fri May 19 15:01:13 2023 -0600

    [FIX] field_service_stage_server_action
  • Loading branch information
Antonio Rivera committed Jul 3, 2023
1 parent c177ae7 commit 9bff471
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions fieldservice_stage_server_action/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,28 @@ def create(self, vals_list):

def write(self, vals):
res = super().write(vals)
action = (
self.env["fsm.stage"].browse(vals["stage_id"]).action_id
if "stage_id" in vals
else None
)
if action:
if "stage_id" in vals:
for record in self:
context = {
"active_model": record._name,
"active_ids": record.ids,
}
action.with_context(**context).run()
if record.stage_id.id != vals.get("stage_id"):
action = (
self.env["fsm.stage"].browse(vals["stage_id"]).action_id
if "stage_id" in vals
else None
)
if action:
context = {
"active_model": record._name,
"active_ids": record.ids,
}
action.with_context(**context).run()
else:
self.activity_ids.create(
{
"res_id": self.id,
"res_model_id": self.env["ir.model"]
.search([("model", "=", "fsm.order")], limit=1)
.id,
"activity_type_id": 1,
}
)
return res

0 comments on commit 9bff471

Please sign in to comment.