diff --git a/account_move_line_rma_order_line/__init__.py b/account_move_line_rma_order_line/__init__.py index 0ab02f92..e7cb8a0c 100644 --- a/account_move_line_rma_order_line/__init__.py +++ b/account_move_line_rma_order_line/__init__.py @@ -14,19 +14,19 @@ def post_init_hook(cr, registry): aml_moves = aml_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 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 and x.account_id.id != x.product_id.categ_id.property_stock_valuation_account_id.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 and not x.rma_line_id and aml_w_rma.name in x.name ) - if invoice_lines_without_rma: - invoice_lines_without_rma.write( + if move_lines_without_rma: + move_lines_without_rma.write( { "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( lambda x: x.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 diff --git a/account_move_line_rma_order_line/__manifest__.py b/account_move_line_rma_order_line/__manifest__.py index b8556c82..285f3c1d 100644 --- a/account_move_line_rma_order_line/__manifest__.py +++ b/account_move_line_rma_order_line/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Account Move Line Rma Order Line", "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)", "website": "https://github.com/ForgeFlow/stock-rma", "category": "Generic", diff --git a/account_move_line_rma_order_line/migrations/14.0.1.1.0/post-migration.py b/account_move_line_rma_order_line/migrations/14.0.1.1.0/post-migration.py new file mode 100644 index 00000000..0ecd26e3 --- /dev/null +++ b/account_move_line_rma_order_line/migrations/14.0.1.1.0/post-migration.py @@ -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)