From 8346461634edf2e107a9512d8914cabcc8bf0ace Mon Sep 17 00:00:00 2001 From: jem-odoo Date: Mon, 25 Jun 2018 10:22:23 +0200 Subject: [PATCH] [FIX] sale: SO line autocreation for vendor bill only On a sale order, when adding a line with an expensable product with a reinvoice policy, on the linked invoiced validation, the analytic entries are created. During this creation, the line will be reinvoiced, so a second SO line will appears with the same product. This should not happen, as the SO line creation from an AAL should be done only when the amount is negative (meaning it comes from an expense or a vendor bill). This was introduced in 3bf8a62e0dd99f7dad42718f895abf4fd53f996f. --- addons/sale/models/analytic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/models/analytic.py b/addons/sale/models/analytic.py index c836f337c9e..3a49bdee295 100644 --- a/addons/sale/models/analytic.py +++ b/addons/sale/models/analytic.py @@ -19,7 +19,7 @@ class AccountAnalyticLine(models.Model): @api.model def create(self, values): result = super(AccountAnalyticLine, self).create(values) - if 'so_line' not in values and not result.so_line and result.product_id and result.product_id.expense_policy != 'no': # allow to force a False value for so_line + if 'so_line' not in values and not result.so_line and result.product_id and result.product_id.expense_policy != 'no' and result.amount <= 0: # allow to force a False value for so_line result.sudo()._sale_determine_order_line() return result