[FIX] stock_account: reconcile same product only

-Create 3 products with different costing methods: AVCO, FIFO, Standard
-Create a PO for the 3 items (same quantity and unit price in every line)
-Receive
-Create Vendor Bill
-Check Journal items.

You will notice that the AVCO product is marked as partially matched. Please keep
in mind that this only happens when the 3 costings are used and the unit price
is the same.

It happes because `_get_all_related_aml` returns all the
`account.move.line` for the journal entry and invoice.
But not only for the current product. So if they share the same
price unit then it could reconcile lines for different products.

X-original-commit: 23ccf2c1bde84f03aaaedb206e37a35de701da5e
Part-of: odoo/odoo#114987
This commit is contained in:
Arnold Moyaux
2023-03-13 10:53:03 +01:00
parent 62a08bfa0a
commit e19bbf8c89
+2 -1
View File
@@ -235,7 +235,8 @@ class AccountMove(models.Model):
# Search for anglo-saxon lines linked to the product in the stock moves.
product_stock_moves = stock_moves.filtered(lambda stock_move: stock_move.product_id == prod)
product_account_moves |= product_stock_moves._get_all_related_aml().filtered(
lambda line: line.account_id == product_interim_account and not line.reconciled and line.move_id.state == "posted"
lambda line: line.account_id == product_interim_account and not line.reconciled and line.move_id.state == "posted" and
line.product_id == prod
)
# Reconcile.