diff --git a/l10n_it_riba/models/__init__.py b/l10n_it_riba/models/__init__.py index d39f3aa987be..b776ccef2caf 100644 --- a/l10n_it_riba/models/__init__.py +++ b/l10n_it_riba/models/__init__.py @@ -8,7 +8,6 @@ from . import account from . import account_config -from . import bank_statement from . import ir_ui_menu from . import partner from . import riba diff --git a/l10n_it_riba/models/account.py b/l10n_it_riba/models/account.py index 27c66633e333..362ac4a9046e 100644 --- a/l10n_it_riba/models/account.py +++ b/l10n_it_riba/models/account.py @@ -7,7 +7,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import _, api, fields, models -from odoo.exceptions import Warning as UserError +from odoo.exceptions import UserError class AccountPaymentTerm(models.Model): @@ -89,8 +89,8 @@ def _compute_is_past_due(self): ) @api.model_create_multi - def create(self, vals): - invoices = super().create(vals) + def create(self, vals_list): + invoices = super().create(vals_list) for invoice in invoices: if not invoice.riba_partner_bank_id: invoice._onchange_riba_partner_bank_id() @@ -201,7 +201,7 @@ def action_post(self): def button_draft(self): # ---- Delete Collection Fees Line of invoice when set Back to Draft # ---- line was added on new validate - res = super(AccountMove, self).button_draft() + res = super().button_draft() for invoice in self: due_cost_line_ids = invoice.get_due_cost_line_ids() if due_cost_line_ids: @@ -230,16 +230,19 @@ def button_cancel(self): if len(riba_line_ids) > 1: riba_line_ids = riba_line_ids[0] raise UserError( - _("Invoice is linked to RiBa slip No. {riba}").format( - riba=riba_line_ids.riba_line_id.slip_id.name + _( + "Invoice is linked to RiBa slip No. %(riba)s", + riba=riba_line_ids.riba_line_id.slip_id.name, ) ) - return super(AccountMove, self).button_cancel() + return super().button_cancel() def copy(self, default=None): self.ensure_one() # Delete Collection Fees Line of invoice when copying - invoice = super(AccountMove, self).copy(default) + invoice = super().copy( + default=default, + ) if invoice: due_cost_line_ids = invoice.get_due_cost_line_ids() if due_cost_line_ids: @@ -295,13 +298,19 @@ def fields_view_get( if ids and view_id == view_payments_tree_id[1]: # Use RiBa slip result = super(models.Model, self).fields_view_get( - view_id, view_type, toolbar=toolbar, submenu=submenu + view_id=view_id, + view_type=view_type, + toolbar=toolbar, + submenu=submenu, ) else: # Use special views for account.move.line object # (for ex. tree view contains user defined fields) - result = super(AccountMoveLine, self).fields_view_get( - view_id, view_type, toolbar=toolbar, submenu=submenu + result = super().fields_view_get( + view_id=view_id, + view_type=view_type, + toolbar=toolbar, + submenu=submenu, ) return result @@ -322,7 +331,7 @@ def update_paid_riba_lines(self): riba_line.slip_id.state = "paid" def reconcile(self): - res = super(AccountMoveLine, self).reconcile() + res = super().reconcile() for line in self: line.update_paid_riba_lines() return res @@ -371,7 +380,7 @@ def unlink(self): riba_lines = None for rec in self: riba_lines = rec.get_riba_lines() - res = super(AccountFullReconcile, self).unlink() + res = super().unlink() if riba_lines: self.unreconcile_riba_lines(riba_lines) return res @@ -384,7 +393,7 @@ def unlink(self): riba_lines = None for rec in self: riba_lines = rec.get_riba_lines() - res = super(AccountPartialReconcile, self).unlink() + res = super().unlink() if riba_lines: self.env["account.full.reconcile"].unreconcile_riba_lines(riba_lines) return res diff --git a/l10n_it_riba/models/account_config.py b/l10n_it_riba/models/account_config.py index 3a93011d3f9d..95e7b1928748 100644 --- a/l10n_it_riba/models/account_config.py +++ b/l10n_it_riba/models/account_config.py @@ -22,8 +22,8 @@ class ResConfigSettings(models.TransientModel): ) @api.model - def default_get(self, fields): - res = super(ResConfigSettings, self).default_get(fields) + def default_get(self, fields_list): + res = super().default_get(fields_list) if res: res["due_cost_service_id"] = self.env.user.company_id.due_cost_service_id.id return res diff --git a/l10n_it_riba/models/bank_statement.py b/l10n_it_riba/models/bank_statement.py deleted file mode 100644 index 24eb7c1affc3..000000000000 --- a/l10n_it_riba/models/bank_statement.py +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright 2018 Lorenzo Battistini - Agile Business Group -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import models -from odoo.osv import expression - - -class AccountBankStatementLine(models.Model): - _inherit = "account.bank.statement.line" - - def get_move_lines_for_reconciliation( - self, - excluded_ids=None, - string=False, - offset=0, - limit=None, - additional_domain=None, - overlook_partner=False, - partner_id=None, - ): - res = super(AccountBankStatementLine, self).get_move_lines_for_reconciliation( - excluded_ids=excluded_ids, - string=string, - offset=offset, - limit=limit, - additional_domain=additional_domain, - overlook_partner=overlook_partner, - ) - - reconciliation_aml_accounts = [ - self.journal_id.default_credit_account_id.id, - self.journal_id.default_debit_account_id.id, - ] - ctx = dict(self._context or {}) - ctx["bank_statement_line"] = self - generic_domain = ( - self.env["account.move.line"] - .with_context(**ctx) - .domain_move_lines_for_reconciliation(str=str) - ) - - # Include move lines without payment_id but linked to a RiBa slip - # in order to allow closing bank statement lines with credited - # journal items - credited_domain = [ - "&", - "&", - "&", - ("move_id.riba_credited_ids", "!=", False), - ("payment_id", "=", False), - ("statement_id", "=", False), - ("account_id", "in", reconciliation_aml_accounts), - ] - credited_domain = expression.AND([credited_domain, generic_domain]) - credited_res = self.env["account.move.line"].search( - credited_domain, - offset=offset, - limit=limit, - order="date_maturity asc, id asc", - ) - - # Include move lines without payment_id but linked to a RiBa slip - # in order to allow closing bank statement lines with past due - # journal items - past_due_domain = [ - "&", - "&", - "&", - ("move_id.riba_past_due_ids", "!=", False), - ("payment_id", "=", False), - ("statement_id", "=", False), - ("account_id", "in", reconciliation_aml_accounts), - ] - past_due_domain = expression.AND([past_due_domain, generic_domain]) - past_due_res = self.env["account.move.line"].search( - past_due_domain, - offset=offset, - limit=limit, - order="date_maturity asc, id asc", - ) - - res = credited_res | past_due_res | res - return res diff --git a/l10n_it_riba/models/riba.py b/l10n_it_riba/models/riba.py index d2bf508c06a9..5def4f8de6fe 100644 --- a/l10n_it_riba/models/riba.py +++ b/l10n_it_riba/models/riba.py @@ -9,7 +9,7 @@ from datetime import date from odoo import _, api, fields, models -from odoo.exceptions import Warning as UserError +from odoo.exceptions import UserError class RibaList(models.Model): @@ -140,9 +140,10 @@ def _unlink_if_not_confirmed(self): raise UserError( _( "Slip %(name)s is in state '%(state)s'. You can only delete documents" - " in state 'Draft' or 'Canceled'." + " in state 'Draft' or 'Canceled'.", + name=riba_list.name, + state=riba_list.state, ) - % {"name": riba_list.name, "state": riba_list.state} ) def confirm(self): @@ -173,7 +174,7 @@ def _onchange_date(self): if self.date_accepted and self.date_credited: if self.date_accepted > self.date_credited: raise UserError( - _("Credit date must be greater or equal to" " acceptance date.") + _("Credit date must be greater or equal to acceptance date.") ) def riba_past_due(self): diff --git a/l10n_it_riba/tests/riba_common.py b/l10n_it_riba/tests/riba_common.py index f7bccb5bc77e..aa5f54394076 100644 --- a/l10n_it_riba/tests/riba_common.py +++ b/l10n_it_riba/tests/riba_common.py @@ -4,7 +4,7 @@ class TestRibaCommon(common.TransactionCase): def setUp(self): - super(TestRibaCommon, self).setUp() + super().setUp() tax_model = self.env["account.tax"] self.account_tax = ( self.env.ref("l10n_it.2601", raise_if_not_found=False) diff --git a/l10n_it_riba/tests/test_riba.py b/l10n_it_riba/tests/test_riba.py index 24d0e3977d50..2935d8d8abc8 100644 --- a/l10n_it_riba/tests/test_riba.py +++ b/l10n_it_riba/tests/test_riba.py @@ -12,9 +12,6 @@ class TestInvoiceDueCost(riba_common.TestRibaCommon): - def setUp(self): - super(TestInvoiceDueCost, self).setUp() - def test_add_due_cost(self): # ---- Set Service in Company Config self.invoice.company_id.due_cost_service_id = self.service_due_cost.id diff --git a/l10n_it_riba/wizard/wizard_riba_file_export.py b/l10n_it_riba/wizard/wizard_riba_file_export.py index a6130b4d6a18..9bcb24f319c4 100644 --- a/l10n_it_riba/wizard/wizard_riba_file_export.py +++ b/l10n_it_riba/wizard/wizard_riba_file_export.py @@ -75,20 +75,6 @@ class RibaFileExport(models.TransientModel): _description = "RiBa File Export Wizard" _ribaStorage = RibaStorage() - # @classmethod - # def _build_model_attributes(cls, pool): - # """ Initialize base model attributes. """ - # ret = super(RibaFileExport,cls)._build_model_attributes( pool) - # cls.sequence = 0 - # cls.creditor_bank = 0 - # cls.sia = 0 - # cls.riba_date = 0 - # cls.support = 0 - # cls.riba_total = 0 - # cls.riba_creditor = 0 - # cls.riba_description = '' - # cls.riba_debtor_city_province = '' - def _RecordIB( self, sia_creditor_bank, @@ -306,7 +292,12 @@ def act_getfile(self): credit_cab = credit_iban[10:15] credit_account = credit_iban[-12:] if not credit_bank.codice_sia: - raise UserError(_("No SIA Code specified for ") + company_name) + raise UserError( + _( + "No SIA Code specified for %(company)s", + company=company_name, + ) + ) credit_sia = credit_bank.codice_sia issued_date = datetime.datetime.now().strftime("%d%m%y") support_name = datetime.datetime.now().strftime("%d%m%y%H%M%S") + credit_sia @@ -316,7 +307,12 @@ def act_getfile(self): not order_obj.config_id.company_id.partner_id.vat and not order_obj.config_id.company_id.partner_id.fiscalcode ): - raise UserError(_("No VAT or Fiscal Code specified for ") + company_name) + raise UserError( + _( + "No VAT or Fiscal Code specified for %(company)s", + company=company_name, + ) + ) array_header = [ credit_sia, credit_abi, @@ -350,7 +346,10 @@ def act_getfile(self): debit_cab = debit_iban[10:15] else: raise UserError( - _("No IBAN or ABI/CAB specified for ") + line.partner_id.name + _( + "No IBAN or ABI/CAB specified for %(partner)s", + partner=line.partner_id.name, + ) ) debtor_city = ( debtor_address.city and debtor_address.city.ljust(23)[0:23] or "" @@ -365,7 +364,10 @@ def act_getfile(self): if not line.partner_id.vat and not line.partner_id.fiscalcode: raise UserError( - _("No VAT or Fiscal Code specified for ") + line.partner_id.name + _( + "No VAT or Fiscal Code specified for %(partner)s", + partner=line.partner_id.name, + ) ) riba = [ line.sequence, diff --git a/l10n_it_riba/wizard/wizard_riba_issue.py b/l10n_it_riba/wizard/wizard_riba_issue.py index 9958481942f2..d002a6ccbcc3 100644 --- a/l10n_it_riba/wizard/wizard_riba_issue.py +++ b/l10n_it_riba/wizard/wizard_riba_issue.py @@ -6,7 +6,8 @@ # Copyright (C) 2012-2017 Lorenzo Battistini - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import _, exceptions, fields, models +from odoo import _, fields, models +from odoo.exceptions import UserError # ------------------------------------------------------- @@ -86,9 +87,11 @@ def create_rdl( if move_line.move_id.riba_partner_bank_id: bank_id = move_line.move_id.riba_partner_bank_id else: - raise exceptions.Warning( - _("No bank has been specified for invoice %s") - % move_line.move_id.name + raise UserError( + _( + "No bank has been specified for invoice %(invoice)s", + invoice=move_line.move_id.name, + ) ) if move_line.partner_id.group_riba and do_group_riba: for key in grouped_lines: