mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: qty to invoice to 0 if total amount is 0
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user