[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 3bf8a62e0d.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user