In pos.order.line , I added a boolean field ; I added 2 fields compute; I want to get the sum of lines into 2 fields according to boolean value:
sum of (qty * price_unit) of lines with boolean False in 'amount1'
sum of (qty * price_unit) of lines with boolean True in 'amount2'
How can I do it please?
class PosOrder(models.Model):
_inherit = "pos.order"
amount1 = fields.Monetary(compute='_compute_amount1', readonly=True)
amount2 = fields.Monetary(compute='_compute_amount2', readonly=True)
@api.depends('payment_ids', 'lines')
def _compute_amount_ht(self):
for line in self.lines:
if line.is_false == True:
self.amount1 += line.qty * line.price_unit
else:
self.amount2 += line.qty * line.price_unit
class PosOrderLine(models.Model):
_inherit = "pos.order.line"
is_false = fields.Boolean(default=False)