on the new Sales Orders page, I added a checkbox to be true if the (unit price > cost) in the order Lines table
the problem is I need to find out if all the checkboxes in the order Lines table are true then set a checkbox outside the table to be true but I can't find out how
in x_studio_check_min_cost compute when I add this
for record in self:
for one_check in record.invoice_ids.invoice_line_ids.sale_line_ids.x_studio_min_price_sale_by_cost:
if one_check == True:
record[('x_studio_check_min_cost')] = True
else:
record[('x_studio_check_min_cost')] = False
in the sales order, this error appears
File "", line 2, in <module>
ValueError: <class 'TypeError'>: "'bool' object is not iterable" while evaluating
"for record in self:\n for one_check in record.invoice_ids.invoice_line_ids.sale_line_ids.x_studio_min_price_sale_by_cost:\n if one_check == True:\n record[('x_studio_check_min_cost')] = True\n else:\n record[('x_studio_check_min_cost')] = False\n"
I am using odoo studio as I am new to odoo and have no experience creating modules
thank you for the help
Checkout this code ,hope it will help.
for record in self:
flag = False
if any(line.x_studio_min_price_sale_by_cost for line in record.order_line):
flag = True
if not flag:
record['x_studio_check_min_cost'] = True
In the compute option of the field x_studio_check_min_cost
,
you can see the Advanced Properties head, right ? Below that in the Dependencies field set the field name as order_line , in the Compute field copy paste the above code (Beware of the Indentation).