summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2017-03-28 08:49:39 +0200
committerNicolas Martinelli <nim@odoo.com>2017-03-28 10:30:06 +0200
commitc9545bda308f4db2ba9c8bbef58cc6c21dec3fb6 (patch)
treecbe5a71921f25512b0ba6efda8e1f144f1c007b3
parent7c95c14c06d77e5ebbd7aafd9c0c345b47d27d30 (diff)
[FIX] purchase: invoice status
- Create a PO with a product "Control Purchase Bills" set to "On received quantities". - Validate the PO. The invoice status is "Waiting Bills", while it should be "Bills Received". opw-726245
-rw-r--r--addons/purchase/models/purchase.py6
-rw-r--r--addons/purchase/tests/test_purchase_order.py1
2 files changed, 4 insertions, 3 deletions
diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py
index 8b9cb5d982d..9e22d788527 100644
--- a/addons/purchase/models/purchase.py
+++ b/addons/purchase/models/purchase.py
@@ -47,7 +47,7 @@ class PurchaseOrder(models.Model):
if min_date:
order.date_planned = min_date
- @api.depends('state', 'order_line.qty_invoiced', 'order_line.product_qty')
+ @api.depends('state', 'order_line.qty_invoiced', 'order_line.qty_received', 'order_line.product_qty')
def _get_invoiced(self):
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
for order in self:
@@ -55,9 +55,9 @@ class PurchaseOrder(models.Model):
order.invoice_status = 'no'
continue
- if any(float_compare(line.qty_invoiced, line.product_qty, precision_digits=precision) == -1 for line in order.order_line):
+ if any(float_compare(line.qty_invoiced, line.product_qty if line.product_id.purchase_method == 'purchase' else line.qty_received, precision_digits=precision) == -1 for line in order.order_line):
order.invoice_status = 'to invoice'
- elif all(float_compare(line.qty_invoiced, line.product_qty, precision_digits=precision) >= 0 for line in order.order_line):
+ elif all(float_compare(line.qty_invoiced, line.product_qty if line.product_id.purchase_method == 'purchase' else line.qty_received, precision_digits=precision) >= 0 for line in order.order_line):
order.invoice_status = 'invoiced'
else:
order.invoice_status = 'no'
diff --git a/addons/purchase/tests/test_purchase_order.py b/addons/purchase/tests/test_purchase_order.py
index 66516e58f99..a7b83a0e237 100644
--- a/addons/purchase/tests/test_purchase_order.py
+++ b/addons/purchase/tests/test_purchase_order.py
@@ -22,6 +22,7 @@ class TestPurchaseOrder(AccountingTestCase):
self.product_id_1 = self.env.ref('product.product_product_8')
self.product_id_2 = self.env.ref('product.product_product_11')
+ (self.product_id_1 | self.product_id_2).write({'purchase_method': 'purchase'})
# Ensure product_id_2 doesn't have res_partner_1 as supplier
if self.partner_id in self.product_id_2.seller_ids.mapped('name'):
id_to_remove = self.product_id_2.seller_ids.filtered(lambda r: r.name == self.partner_id).ids[0] if self.product_id_2.seller_ids.filtered(lambda r: r.name == self.partner_id) else False