From 8f61196b58650557b9adacfc4964f82d6454ff3f Mon Sep 17 00:00:00 2001 From: Michele Rusticucci <102949020+michelerusti@users.noreply.github.com> Date: Thu, 29 Dec 2022 10:41:56 +0100 Subject: [PATCH] 14.0 fix l10n it declaration of intent (#4) * 14.0 - FIX - l10n_it_declaration_of_intent - Fixed autovalidating credit note * [14.0][FIX]-l10n_it_declaration_of_intent - calling action_post() on multiple invoices does not update declaration amount in check methods * [14.0][FIX] l10n_it_declaration_of_intent | used better condition to check string in string --- .../models/account_move.py | 16 ++++++---------- .../readme/CONTRIBUTORS.rst | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/l10n_it_declaration_of_intent/models/account_move.py b/l10n_it_declaration_of_intent/models/account_move.py index bc5967f14524..e2f85b4e0570 100644 --- a/l10n_it_declaration_of_intent/models/account_move.py +++ b/l10n_it_declaration_of_intent/models/account_move.py @@ -1,4 +1,5 @@ # Copyright 2017 Francesco Apruzzese +# Copyright 2022 Michele Rusticucci # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import _, api, fields, models @@ -77,8 +78,8 @@ def select_manually_declarations(self): ).read()[0] return action - def action_post(self): - res = super().action_post() + def _post(self, soft=True): + posted = super()._post(soft) # Check if there is enough available amount on declarations for invoice in self: declarations = invoice.get_declarations() @@ -98,12 +99,7 @@ def action_post(self): invoice.check_declarations_amounts(declarations) - # Assign account move lines to declarations for each invoice - for invoice in self: - declarations = invoice.get_declarations() - # If partner has no declarations, do nothing - if not declarations: - continue + # Assign account move lines to declarations for each invoice # Get only lines with taxes lines = invoice.line_ids.filtered("tax_ids") if not lines: @@ -112,7 +108,7 @@ def action_post(self): grouped_lines = self.get_move_lines_by_declaration(lines) invoice.update_declarations(declarations, grouped_lines) - return res + return posted def update_declarations(self, declarations, grouped_lines): """ @@ -265,7 +261,7 @@ def get_declaration_residual_amounts(self, declarations): tax_lines = self.line_ids.filtered("tax_ids") for tax_line in tax_lines: # Move lines having `tax_ids` represent the base amount for those taxes - if "refund" in self.move_type: + if self.move_type.endswith("_refund"): amount = -tax_line.price_subtotal else: amount = tax_line.price_subtotal diff --git a/l10n_it_declaration_of_intent/readme/CONTRIBUTORS.rst b/l10n_it_declaration_of_intent/readme/CONTRIBUTORS.rst index 8b87edfd5e24..de0f1299c528 100644 --- a/l10n_it_declaration_of_intent/readme/CONTRIBUTORS.rst +++ b/l10n_it_declaration_of_intent/readme/CONTRIBUTORS.rst @@ -6,3 +6,4 @@ * Simone Rubino * Arcadio Pinto * Alex Comba +* Michele Rusticucci