Fix: Operador And y total_amount_cache != None

This commit is contained in:
sinergia 2024-11-10 18:18:14 -05:00
parent 8211278e78
commit a4e9001bd6

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains the full # The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms. # copyright notices and license terms.
from decimal import Decimal from decimal import Decimal
from sql.operators import And
from sql.aggregate import Sum from sql.aggregate import Sum
from sql.conditionals import Coalesce from sql.conditionals import Coalesce
@ -162,13 +163,14 @@ class Sale(metaclass=PoolMeta):
condition=(sale.id == payline.sale) condition=(sale.id == payline.sale)
).select( ).select(
sale.id, sale.id,
where=((sale.total_amount_cache) & ( where=(And([
sale.total_amount_cache != None,
sale.state.in_([ sale.state.in_([
'draft', 'draft',
'quotation', 'quotation',
'confirmed', 'confirmed',
'processing', 'processing',
'done']))), 'done'])])),
group_by=(sale.id), group_by=(sale.id),
having=(Operator( having=(Operator(
sale.total_amount_cache - Sum( sale.total_amount_cache - Sum(