I would like to create a Actions Scheduled to update my value via the function: or sql command to do this
@ api.onchange ('x_effective_date', 'x_contract_duration')
def _onchange_x_effective_date (self):
if self.x_effective_date:
start_datetime = datetime.strptime (self.x_effective_date, "% Y-% m-% d% H:% M:% S")
if self.x_contract_duration! = 0:
self.x_contract_enddate = start_datetime + monthdelta (self.x_contract_duration) - timedelta (days = 1)
-------- I also created a new def to make a call in the Scheduled Actions, but failed,
@ api.model
def set_contract_enddate (self):
cho rec in self:
rec._onchange_x_effective_date ()
"" ValueError: <class 'NameError'>: "name 'set_contract_enddate' is not defined" while Evaluating
'set_contract_enddate' ", please tell me, thanks