Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2231 Prikazi

Hello,


For our Business we sell products sold by m², but packaged by box. eg. We can't sell 1 m², this needs to be rounded to full packages of 1,08m². 


I use an automated action for this, and it works fine for orders in concept state. However on cofirmed orders I get an (blank) error. I Suspected it had something to do with the read-only modifier on order_lines, but after removing the read-only flag the error remains.

On a confirmed order I receive an error with a very strange accompanying log entry:


Error in Log

raise ValueError(_('Posting a message should be done on a business document. Use message_notify to send a notification to an user.'))

Automated action code

def ceil(value):
return (value - (value%1))+1

product_packaging = record.product_id.x_studio_packaging
product_uom = record.product_id.uom_id
product_packaging_content = float(record.product_id.x_studio_packaging_content)
product_uom_qty = float(record.product_uom_qty)

if product_packaging and product_packaging_content > 0 and product_packaging != product_uom:
product_package_count = product_uom_qty / product_packaging_content
if prodct_package_count - int(product_package_count) != 0:
new_product_uom_qty = ceil(product_package_count) * product_packaging_content
record.write({
'product_uom_qty': new_product_uom_qty,
})

Anybody any idea how to write the sale.order.line to a confirmed order from an automated action?

Thanks!


Avatar
Opusti
Avtor

Not sure why, but after fiddling/google-ing around and replacing record.write with record.update it seems to be working!