[FIX] account_move_line_rma_order_line: Force to trigger again the init hook.

As the script was incorrect in previous versions.
This commit is contained in:
Jordi Ballester
2022-03-02 14:51:41 +01:00
committed by AlexPForgeFlow
parent f3bf3f3b3f
commit 86fadeb438
3 changed files with 21 additions and 5 deletions

View File

@@ -14,19 +14,19 @@ def post_init_hook(cr, registry):
aml_moves = aml_model.search([("rma_line_id", "!=", False)]) aml_moves = aml_model.search([("rma_line_id", "!=", False)])
sm_moves = sm_model.search([("rma_line_id", "!=", False)]) sm_moves = sm_model.search([("rma_line_id", "!=", False)])
for account_move in aml_moves.mapped("move_id"): for account_move in aml_moves.mapped("move_id"):
for aml_w_rma in account_move.invoice_line_ids.filtered( for aml_w_rma in account_move.line_ids.filtered(
lambda x: x.product_id lambda x: x.product_id
and x.account_id.id and x.account_id.id
!= x.product_id.categ_id.property_stock_valuation_account_id.id != x.product_id.categ_id.property_stock_valuation_account_id.id
and x.rma_line_id and x.rma_line_id
): ):
invoice_lines_without_rma = account_move.invoice_line_ids.filtered( move_lines_without_rma = account_move.line_ids.filtered(
lambda x: x.product_id.id == aml_w_rma.product_id.id lambda x: x.product_id.id == aml_w_rma.product_id.id
and not x.rma_line_id and not x.rma_line_id
and aml_w_rma.name in x.name and aml_w_rma.name in x.name
) )
if invoice_lines_without_rma: if move_lines_without_rma:
invoice_lines_without_rma.write( move_lines_without_rma.write(
{ {
"rma_line_id": aml_w_rma.rma_line_id.id, "rma_line_id": aml_w_rma.rma_line_id.id,
} }
@@ -37,5 +37,6 @@ def post_init_hook(cr, registry):
for aml in current_layers.mapped("account_move_id.line_ids").filtered( for aml in current_layers.mapped("account_move_id.line_ids").filtered(
lambda x: x.account_id.id lambda x: x.account_id.id
!= move.product_id.categ_id.property_stock_valuation_account_id.id != move.product_id.categ_id.property_stock_valuation_account_id.id
and not x.rma_line_id
): ):
aml.rma_line_id = move.rma_line_id.id aml.rma_line_id = move.rma_line_id.id

View File

@@ -4,7 +4,7 @@
{ {
"name": "Account Move Line Rma Order Line", "name": "Account Move Line Rma Order Line",
"summary": "Introduces the rma order line to the journal items", "summary": "Introduces the rma order line to the journal items",
"version": "14.0.1.0.0", "version": "14.0.1.1.0",
"author": "ForgeFlow, " "Odoo Community Association (OCA)", "author": "ForgeFlow, " "Odoo Community Association (OCA)",
"website": "https://github.com/ForgeFlow/stock-rma", "website": "https://github.com/ForgeFlow/stock-rma",
"category": "Generic", "category": "Generic",

View File

@@ -0,0 +1,15 @@
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# Part of ForgeFlow. See LICENSE file for full copyright and licensing details.
import logging
from odoo import SUPERUSER_ID, api
from odoo.addons.account_move_line_rma_order_line import post_init_hook
_logger = logging.getLogger(__name__)
def migrate(cr, version):
_logger.info("Trigger again the post_init_hook")
env = api.Environment(cr, SUPERUSER_ID, {})
post_init_hook(cr, env.registry)