Hello
I am trying to add a server action / contextual action to generate an internal reference for my manufactured products that do not have an internal reference already. The Python code that is executed looks like this:
for record in records:
if record['route_ids' == 6]:
if not record['default_code']:
record['default_code'] = env['ir.sequence'].next_by_code('manufactured_product.default_code')
else:
raise UserError(_("Product is not manufactured."))
I've checked that the "Manufacture" route has ID 6. I want Odoo to only allow generation of internal reference for manufactured products. The problem is that if I try to run this server action on products that are not manufactured (only "Buy" route), the action still runs and generates an internal reference.
I'm obviously doing something wrong here. Anyone with a sharp eye who can see what's wrong with my code?