forked from odoo-italia/l10n-italy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
14.0 fix l10n it declaration of intent (odoo-italia#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
- Loading branch information
1 parent
03b4a46
commit 8f61196
Showing
2 changed files
with
7 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
* Simone Rubino <[email protected]> | ||
* Arcadio Pinto <[email protected]> | ||
* Alex Comba <[email protected]> | ||
* Michele Rusticucci <[email protected]> |