Skip to Content
Menu
This question has been flagged
1 Reply
1871 Views

I setup a scheduler using model=product to execute a python code. 

for record in records:
  if record.qty_available == 0:
    record.website_published = False
  break;

But it is giving the below 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 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# - log: log(message, level='info'): logging function to record debug information in ir.logging table\n# - Warning: Warning Exception to use with raise\n# To return an action, assign: action = {...}\nfor record in records:\n if record.product.qty_available == 0:\n record.product.website_published = False\n break;": STORE_ATTR

Can somebody help what I did wrong? Thanks.

Avatar
Discard
Best Answer

Hi,

You can try the below code,

products = env['product.product'].search([])
for prod in products:
   if .qty_available == 0:
       prod.write({'website_published': False})


Thanks

Avatar
Discard