Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
5680 Ansichten

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

Avatar
Verwerfen
Beste Antwort

You need to create a Scheduled action and call your method from that action. You need to set the proper model so it knows where to look for the method.

Check that you don't have any errors in the code. I don't know what "cho rec in self" means. First try your method with a button and then when it works you can try with the scheduled action. With every change in the code you need to restart the server. 

Avatar
Verwerfen
Autor

for rec in self:

After the update, existing merchants will have a corresponding expiration date.

do you have the correct data in your Settings -> Technical -> Automatization -> Scheduled Actions? Does your method even work calling it from a view with a button???

Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Dez. 19
2704
1
Nov. 23
4189
2
Dez. 19
15814
7
Okt. 19
10414
1
Juli 19
3355