Skip to content

Commit

Permalink
[REF] l10n_it_riba: Use translations placeholders
Browse files Browse the repository at this point in the history
Cleanup old syntax super(Class, instance) -> super()
Remove unused code
  • Loading branch information
SirAionTech committed Sep 28, 2023
1 parent 5821813 commit e12f143
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 130 deletions.
1 change: 0 additions & 1 deletion l10n_it_riba/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 23 additions & 14 deletions l10n_it_riba/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions l10n_it_riba/models/account_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
83 changes: 0 additions & 83 deletions l10n_it_riba/models/bank_statement.py

This file was deleted.

9 changes: 5 additions & 4 deletions l10n_it_riba/models/riba.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion l10n_it_riba/tests/riba_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions l10n_it_riba/tests/test_riba.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 20 additions & 18 deletions l10n_it_riba/wizard/wizard_riba_file_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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 ""
Expand All @@ -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,
Expand Down
11 changes: 7 additions & 4 deletions l10n_it_riba/wizard/wizard_riba_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


# -------------------------------------------------------
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit e12f143

Please sign in to comment.