[IMP]pms: qty to invoice to 0 if total amount is 0

This commit is contained in:
Darío Lodeiros
2022-02-22 22:34:51 +01:00
parent e5988293ea
commit eb7f81cffc
2 changed files with 5 additions and 4 deletions

View File

@@ -506,7 +506,7 @@ class FolioSaleLine(models.Model):
"Product Unit of Measure"
)
for line in self:
if line.state == "draft":
if line.state == "draft" or line.price_total == 0.0:
line.invoice_status = "no"
# REVIEW: if qty_to_invoice < 0 (invoice qty > sale qty),
# why status to_invoice?? this behavior is copied from sale order
@@ -625,7 +625,7 @@ class FolioSaleLine(models.Model):
Otherwise, the quantity delivered is used.
"""
for line in self:
if line.folio_id.state not in ["draft"]:
if line.folio_id.state not in ["draft"] and line.price_total > 0.0:
line.qty_to_invoice = line.product_uom_qty - line.qty_invoiced
else:
line.qty_to_invoice = 0

View File

@@ -814,9 +814,10 @@ class PmsFolio(models.Model):
- to_invoice: if any SO line is 'to_invoice', the whole SO is 'to_invoice'
- invoiced: if all SO lines are invoiced, the SO is invoiced.
"""
unconfirmed_orders = self.filtered(lambda so: so.state in ["draft"])
unconfirmed_orders = self.filtered(lambda folio: folio.state in ["draft"])
unconfirmed_orders.invoice_status = "no"
confirmed_orders = self - unconfirmed_orders
zero_orders = self.filtered(lambda folio: folio.amount_total == 0)
confirmed_orders = self - unconfirmed_orders - zero_orders
if not confirmed_orders:
return
line_invoice_status_all = [