Skip to content

Commit

Permalink
14.0 fix l10n it declaration of intent (odoo-italia#4)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
michelerusti authored and Borruso committed Jul 7, 2023
1 parent 03b4a46 commit 8f61196
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
16 changes: 6 additions & 10 deletions l10n_it_declaration_of_intent/models/account_move.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2017 Francesco Apruzzese <[email protected]>
# Copyright 2022 Michele Rusticucci <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
Expand Down Expand Up @@ -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()
Expand All @@ -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:
Expand All @@ -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):
"""
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions l10n_it_declaration_of_intent/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
* Simone Rubino <[email protected]>
* Arcadio Pinto <[email protected]>
* Alex Comba <[email protected]>
* Michele Rusticucci <[email protected]>

0 comments on commit 8f61196

Please sign in to comment.