Skip to content

Commit

Permalink
[FIX] fieldservice: request_late calc based on settings
Browse files Browse the repository at this point in the history
  • Loading branch information
brian10048 committed Nov 13, 2023
1 parent 2416adb commit 41ea5c0
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions fieldservice/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def _track_subtype(self, init_values):
help="Company related to this order",
)

def _compute_request_late(self, vals):
def _calc_request_late(self, vals):
if vals.get("request_early", False):
early = fields.Datetime.from_string(vals.get("request_early"))
else:
Expand Down Expand Up @@ -253,26 +253,7 @@ def create(self, vals_list):
)
self._calc_scheduled_dates(vals)
if not vals.get("request_late"):
if vals.get("priority") == "0":
if vals.get("request_early"):
vals["request_late"] = fields.Datetime.from_string(
vals.get("request_early")
) + timedelta(days=3)
else:
vals["request_late"] = datetime.now() + timedelta(days=3)
elif vals.get("request_early") and vals.get("priority") == "1":
vals["request_late"] = fields.Datetime.from_string(
vals.get("request_early")
) + timedelta(days=2)
elif vals.get("request_early") and vals.get("priority") == "2":
vals["request_late"] = fields.Datetime.from_string(
vals.get("request_early")
) + timedelta(days=1)
elif vals.get("request_early") and vals.get("priority") == "3":
vals["request_late"] = fields.Datetime.from_string(
vals.get("request_early")
) + timedelta(hours=8)

vals = self._calc_request_late(vals)
return super().create(vals_list)

is_button = fields.Boolean(default=False)
Expand Down

0 comments on commit 41ea5c0

Please sign in to comment.