[FIX] purchase_stock: Wrong journal entry created from vendor bill
Steps to reproduce: - Create a storable product P with a vendor V and a purchase price = 100€ - Set the category of the prodcut to automated and AVCO and set a price diff account on it - Create PO for V with 10 P with a price_unit = 110€ - Confirm the PO and deliver 7 P with no backorder - Change the ordered quantity of P to 9 on PO (and the unit_price will be set to 100€) - Go on the delivery order and deliver 2 remainig P - Create the invoice and validate it Bug: The amount due on the invoice was 900.02€ instead of 900.00€ PS: The debit and credit of an aml are computed with the price (defined in function _anglo_saxon_purchase_move_lines) with the function _convert_prepared_anglosaxon_line defined on model account.invoice. So rounding the price unit after the computation of the price allows to keep the same total as the one computed for the PO. opw:1951465 closes odoo/odoo#32345 Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
@@ -123,7 +123,7 @@ class AccountInvoice(models.Model):
|
||||
diff_line = {
|
||||
'type': 'src',
|
||||
'name': i_line.name[:64],
|
||||
'price_unit': inv.currency_id.round(price_unit_val_dif),
|
||||
'price_unit': price_unit_val_dif,
|
||||
'quantity': line_quantity,
|
||||
'price': inv.currency_id.round(price_val_dif),
|
||||
'account_id': acc,
|
||||
@@ -133,8 +133,9 @@ class AccountInvoice(models.Model):
|
||||
'tax_ids': tax_ids,
|
||||
}
|
||||
# We update the original line accordingly
|
||||
line['price_unit'] = inv.currency_id.round(line['price_unit'] - diff_line['price_unit'])
|
||||
line['price_unit'] = line['price_unit'] - diff_line['price_unit']
|
||||
line['price'] = inv.currency_id.round(line['quantity'] * line['price_unit'])
|
||||
line['price_unit'] = inv.currency_id.round(line['price_unit'])
|
||||
diff_res.append(diff_line)
|
||||
return diff_res
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user