[FIX] stock_account: reconcile kit
Kit were not reconcile because the `_stock_account_anglo_saxon_reconcile_valuation` method try to match `account.move.line` and `stock.move` base on the product field. However in kit case, the moves are exploded in mutliple moves containing the kit's components. Due to that the matching is not made. To fix this issue we use the `purchase.order.line` that is share between the `stock.move` and `account.move.line` to retrieve them. closes odoo/odoo#114987 X-original-commit: f594c837c8a347abb48015d4e9bb0d5109228539 Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
@@ -212,4 +212,10 @@ class StockMove(models.Model):
|
||||
)
|
||||
|
||||
def _get_all_related_aml(self):
|
||||
return super()._get_all_related_aml() | self.purchase_line_id.invoice_lines.move_id.line_ids
|
||||
# The back and for between account_move and account_move_line is necessary to catch the
|
||||
# additional lines from a cogs correction
|
||||
return super()._get_all_related_aml() | self.purchase_line_id.invoice_lines.move_id.line_ids.filtered(
|
||||
lambda aml: aml.product_id == self.purchase_line_id.product_id)
|
||||
|
||||
def _get_all_related_sm(self, product):
|
||||
return super()._get_all_related_sm(product) | self.filtered(lambda m: m.purchase_line_id.product_id == product)
|
||||
|
||||
@@ -233,10 +233,9 @@ class AccountMove(models.Model):
|
||||
lambda line: line.product_id == prod and line.account_id == product_interim_account and not line.reconciled)
|
||||
|
||||
# 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_stock_moves = stock_moves._get_all_related_sm(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" and
|
||||
line.product_id == prod
|
||||
lambda line: line.account_id == product_interim_account and not line.reconciled and line.move_id.state == "posted"
|
||||
)
|
||||
|
||||
# Reconcile.
|
||||
|
||||
@@ -604,3 +604,6 @@ class StockMove(models.Model):
|
||||
|
||||
def _get_all_related_aml(self):
|
||||
return self.account_move_ids.line_ids
|
||||
|
||||
def _get_all_related_sm(self, product):
|
||||
return self.filtered(lambda m: m.product_id == product)
|
||||
|
||||
Reference in New Issue
Block a user