mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[FIX] rma_purchase: Reconcile the interim accounts when vendor bill is posted
This commit is contained in:
committed by
JasminSForgeFlow
parent
0029329101
commit
492425483f
@@ -11,3 +11,31 @@ class AccountMove(models.Model):
|
|||||||
data = super(AccountMove, self)._prepare_invoice_line_from_rma_line(line)
|
data = super(AccountMove, self)._prepare_invoice_line_from_rma_line(line)
|
||||||
data["purchase_line_id"]: line.id
|
data["purchase_line_id"]: line.id
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def action_post(self):
|
||||||
|
res = super(AccountMove, self).action_post()
|
||||||
|
for move in self:
|
||||||
|
rma_mls = move.line_ids.filtered(lambda l: l.rma_line_id)
|
||||||
|
if rma_mls:
|
||||||
|
# Try to reconcile the interim accounts for RMA lines
|
||||||
|
rmas = rma_mls.mapped("rma_line_id")
|
||||||
|
for rma in rmas:
|
||||||
|
product_accounts = (
|
||||||
|
rma.product_id.product_tmpl_id._get_product_accounts()
|
||||||
|
)
|
||||||
|
if rma.type == "customer":
|
||||||
|
product_interim_account = product_accounts["stock_output"]
|
||||||
|
else:
|
||||||
|
product_interim_account = product_accounts["stock_input"]
|
||||||
|
if product_interim_account.reconcile:
|
||||||
|
# Get the in and out moves
|
||||||
|
amls = self.env["account.move.line"].search(
|
||||||
|
[
|
||||||
|
("rma_line_id", "=", rma.id),
|
||||||
|
("account_id", "=", product_interim_account.id),
|
||||||
|
("parent_state", "=", "posted"),
|
||||||
|
("reconciled", "=", False),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
amls.reconcile()
|
||||||
|
return res
|
||||||
|
|||||||
Reference in New Issue
Block a user