forked from OCA/l10n-italy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] l10n_it_fatturapa_in_rc: black, isort, prettier
- Loading branch information
1 parent
67347f7
commit 935dd68
Showing
7 changed files
with
191 additions
and
171 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
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,69 +1,69 @@ | ||
from odoo import models, api, _ | ||
from odoo import _, api, models | ||
from odoo.tools import float_compare | ||
|
||
|
||
class InvoiceLine(models.Model): | ||
_inherit = 'account.invoice.line' | ||
_inherit = "account.invoice.line" | ||
|
||
@api.multi | ||
def _set_rc_flag(self, invoice): | ||
self.ensure_one() | ||
if 'fatturapa.attachment.in' in self.env.context.get( | ||
'active_model', [] | ||
): | ||
if "fatturapa.attachment.in" in self.env.context.get("active_model", []): | ||
# this means we are importing an e-invoice, | ||
# so RC flag is already set, where needed | ||
return | ||
return super(InvoiceLine, self)._set_rc_flag(invoice) | ||
|
||
|
||
class Invoice(models.Model): | ||
_inherit = 'account.invoice' | ||
_inherit = "account.invoice" | ||
|
||
def e_inv_check_amount_tax(self): | ||
if ( | ||
any(self.invoice_line_ids.mapped('rc')) and | ||
self.e_invoice_amount_tax | ||
): | ||
error_message = '' | ||
if any(self.invoice_line_ids.mapped("rc")) and self.e_invoice_amount_tax: | ||
error_message = "" | ||
amount_added_for_rc = self.get_tax_amount_added_for_rc() | ||
amount_tax = self.amount_tax - amount_added_for_rc | ||
if float_compare( | ||
amount_tax, self.e_invoice_amount_tax, | ||
precision_rounding=self.currency_id.rounding | ||
) != 0: | ||
error_message = ( | ||
_("Taxed amount ({bill_amount_tax}) " | ||
"does not match with " | ||
"e-bill taxed amount ({e_bill_amount_tax})") | ||
.format( | ||
bill_amount_tax=amount_tax or 0, | ||
e_bill_amount_tax=self.e_invoice_amount_tax | ||
)) | ||
if ( | ||
float_compare( | ||
amount_tax, | ||
self.e_invoice_amount_tax, | ||
precision_rounding=self.currency_id.rounding, | ||
) | ||
!= 0 | ||
): | ||
error_message = _( | ||
"Taxed amount ({bill_amount_tax}) " | ||
"does not match with " | ||
"e-bill taxed amount ({e_bill_amount_tax})" | ||
).format( | ||
bill_amount_tax=amount_tax or 0, | ||
e_bill_amount_tax=self.e_invoice_amount_tax, | ||
) | ||
return error_message | ||
else: | ||
return super(Invoice, self).e_inv_check_amount_tax() | ||
|
||
def e_inv_check_amount_total(self): | ||
if ( | ||
any(self.invoice_line_ids.mapped('rc')) and | ||
self.e_invoice_amount_total | ||
): | ||
error_message = '' | ||
if any(self.invoice_line_ids.mapped("rc")) and self.e_invoice_amount_total: | ||
error_message = "" | ||
amount_added_for_rc = self.get_tax_amount_added_for_rc() | ||
amount_total = self.amount_total - amount_added_for_rc | ||
if float_compare( | ||
amount_total, self.e_invoice_amount_total, | ||
precision_rounding=self.currency_id.rounding | ||
) != 0: | ||
error_message = ( | ||
_("Total amount ({bill_amount_total}) " | ||
"does not match with " | ||
"e-bill total amount ({e_bill_amount_total})") | ||
.format( | ||
bill_amount_total=amount_total or 0, | ||
e_bill_amount_total=self.e_invoice_amount_total | ||
)) | ||
if ( | ||
float_compare( | ||
amount_total, | ||
self.e_invoice_amount_total, | ||
precision_rounding=self.currency_id.rounding, | ||
) | ||
!= 0 | ||
): | ||
error_message = _( | ||
"Total amount ({bill_amount_total}) " | ||
"does not match with " | ||
"e-bill total amount ({e_bill_amount_total})" | ||
).format( | ||
bill_amount_total=amount_total or 0, | ||
e_bill_amount_total=self.e_invoice_amount_total, | ||
) | ||
return error_message | ||
else: | ||
return super(Invoice, self).e_inv_check_amount_total() |
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,10 +1,10 @@ | ||
from odoo import models, fields | ||
from odoo import fields, models | ||
|
||
|
||
class RCType(models.Model): | ||
_inherit = 'account.rc.type' | ||
_inherit = "account.rc.type" | ||
|
||
e_invoice_suppliers = fields.Boolean( | ||
"E-invoice suppliers", | ||
help="Automatically used when importing e-invoices from Italian " | ||
"suppliers") | ||
help="Automatically used when importing e-invoices from Italian " "suppliers", | ||
) |
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
Oops, something went wrong.