Hi All,
I am trying to schedule an action everyday at 15:00 o clock to automate the confirmation of po.
i create a new scheduled action with this python code but it gives me an error:
this is the code:
from odoo import models, fields
class PurchaseOrder(models.Model):
_name = 'purchase.order'
def action_confirm(self):
for rec in self:
if rec.state == 'draft' or rec.state == 'sent':
rec.button_confirm()
And this is the error:
forbidden opcode(s) in "# Available variables:\n# - env: Odoo Environment on which the action is triggered\n# - model: Odoo Model of the record on which the action is triggered; is a void recordset\n# - record: record on which the action is triggered; may be void\n# - records: recordset of all records on which the action is triggered in multi-mode; may be void\n# - time, datetime, dateutil, timezone: useful Python libraries\n# - float_compare: Odoo function to compare floats based on specific precisions\n# - log: log(message, level='info'): logging function to record debug information in ir.logging table\n# - UserError: Warning Exception to use with raise\n# - Command: x2Many commands namespace\n# To return an action, assign: action = {...}\nfrom odoo import models, fields\nclass PurchaseOrder(models.Model):\n _name = 'purchase.order'\n def action_confirm(self):\n for rec in self:\n if rec.state == 'draft' or rec.state == 'sent':\n rec.button_confirm()": IMPORT_NAME, IMPORT_FROM, LOAD_BUILD_CLASS
Can anybody help me to correct the code?
Thanks in advance.
Kind regards,
Chris