Skip to content

Commit 5a5e002

Browse files
committed
[REF] l10n_it_riba: Use translations placeholders
Cleanup old syntax super(Class, instance) -> super() Remove unused code
1 parent 32367d7 commit 5a5e002

9 files changed

Lines changed: 58 additions & 131 deletions

File tree

l10n_it_riba/models/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
from . import account
1010
from . import account_config
11-
from . import bank_statement
1211
from . import ir_ui_menu
1312
from . import partner
1413
from . import riba

l10n_it_riba/models/account.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
99

1010
from odoo import _, api, fields, models
11-
from odoo.exceptions import Warning as UserError
11+
from odoo.exceptions import UserError
1212

1313

1414
class AccountPaymentTerm(models.Model):
@@ -90,8 +90,8 @@ def _compute_is_past_due(self):
9090
)
9191

9292
@api.model_create_multi
93-
def create(self, vals):
94-
invoices = super().create(vals)
93+
def create(self, vals_list):
94+
invoices = super().create(vals_list)
9595
for invoice in invoices:
9696
if not invoice.riba_partner_bank_id:
9797
invoice._onchange_riba_partner_bank_id()
@@ -202,7 +202,7 @@ def action_post(self):
202202
def button_draft(self):
203203
# ---- Delete Collection Fees Line of invoice when set Back to Draft
204204
# ---- line was added on new validate
205-
res = super(AccountMove, self).button_draft()
205+
res = super().button_draft()
206206
for invoice in self:
207207
due_cost_line_ids = invoice.get_due_cost_line_ids()
208208
if due_cost_line_ids:
@@ -231,16 +231,19 @@ def button_cancel(self):
231231
if len(riba_line_ids) > 1:
232232
riba_line_ids = riba_line_ids[0]
233233
raise UserError(
234-
_("Invoice is linked to RiBa slip No. {riba}").format(
235-
riba=riba_line_ids.riba_line_id.slip_id.name
234+
_(
235+
"Invoice is linked to RiBa slip No. %(riba)s",
236+
riba=riba_line_ids.riba_line_id.slip_id.name,
236237
)
237238
)
238-
return super(AccountMove, self).button_cancel()
239+
return super().button_cancel()
239240

240241
def copy(self, default=None):
241242
self.ensure_one()
242243
# Delete Collection Fees Line of invoice when copying
243-
invoice = super(AccountMove, self).copy(default)
244+
invoice = super().copy(
245+
default=default,
246+
)
244247
if invoice:
245248
due_cost_line_ids = invoice.get_due_cost_line_ids()
246249
if due_cost_line_ids:
@@ -296,13 +299,19 @@ def fields_view_get(
296299
if ids and view_id == view_payments_tree_id[1]:
297300
# Use RiBa slip
298301
result = super(models.Model, self).fields_view_get(
299-
view_id, view_type, toolbar=toolbar, submenu=submenu
302+
view_id=view_id,
303+
view_type=view_type,
304+
toolbar=toolbar,
305+
submenu=submenu,
300306
)
301307
else:
302308
# Use special views for account.move.line object
303309
# (for ex. tree view contains user defined fields)
304-
result = super(AccountMoveLine, self).fields_view_get(
305-
view_id, view_type, toolbar=toolbar, submenu=submenu
310+
result = super().fields_view_get(
311+
view_id=view_id,
312+
view_type=view_type,
313+
toolbar=toolbar,
314+
submenu=submenu,
306315
)
307316
return result
308317

@@ -323,7 +332,7 @@ def update_paid_riba_lines(self):
323332
riba_line.slip_id.state = "paid"
324333

325334
def reconcile(self):
326-
res = super(AccountMoveLine, self).reconcile()
335+
res = super().reconcile()
327336
for line in self:
328337
line.update_paid_riba_lines()
329338
return res
@@ -372,7 +381,7 @@ def unlink(self):
372381
riba_lines = None
373382
for rec in self:
374383
riba_lines = rec.get_riba_lines()
375-
res = super(AccountFullReconcile, self).unlink()
384+
res = super().unlink()
376385
if riba_lines:
377386
self.unreconcile_riba_lines(riba_lines)
378387
return res
@@ -385,7 +394,7 @@ def unlink(self):
385394
riba_lines = None
386395
for rec in self:
387396
riba_lines = rec.get_riba_lines()
388-
res = super(AccountPartialReconcile, self).unlink()
397+
res = super().unlink()
389398
if riba_lines:
390399
self.env["account.full.reconcile"].unreconcile_riba_lines(riba_lines)
391400
return res

l10n_it_riba/models/account_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class ResConfigSettings(models.TransientModel):
2323
)
2424

2525
@api.model
26-
def default_get(self, fields):
27-
res = super(ResConfigSettings, self).default_get(fields)
26+
def default_get(self, fields_list):
27+
res = super().default_get(fields_list)
2828
if res:
2929
res["due_cost_service_id"] = self.env.user.company_id.due_cost_service_id.id
3030
return res

l10n_it_riba/models/bank_statement.py

Lines changed: 0 additions & 84 deletions
This file was deleted.

l10n_it_riba/models/riba.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from datetime import date
1111

1212
from odoo import _, api, fields, models
13-
from odoo.exceptions import Warning as UserError
13+
from odoo.exceptions import UserError
1414

1515

1616
class RibaList(models.Model):
@@ -141,9 +141,10 @@ def _unlink_if_not_confirmed(self):
141141
raise UserError(
142142
_(
143143
"Slip %(name)s is in state '%(state)s'. You can only delete documents"
144-
" in state 'Draft' or 'Canceled'."
144+
" in state 'Draft' or 'Canceled'.",
145+
name=riba_list.name,
146+
state=riba_list.state,
145147
)
146-
% {"name": riba_list.name, "state": riba_list.state}
147148
)
148149

149150
def confirm(self):
@@ -174,7 +175,7 @@ def _onchange_date(self):
174175
if self.date_accepted and self.date_credited:
175176
if self.date_accepted > self.date_credited:
176177
raise UserError(
177-
_("Credit date must be greater or equal to" " acceptance date.")
178+
_("Credit date must be greater or equal to acceptance date.")
178179
)
179180

180181
def riba_past_due(self):

l10n_it_riba/tests/riba_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class TestRibaCommon(common.TransactionCase):
99
def setUp(self):
10-
super(TestRibaCommon, self).setUp()
10+
super().setUp()
1111
tax_model = self.env["account.tax"]
1212
self.account_tax = (
1313
self.env.ref("l10n_it.2601", raise_if_not_found=False)

l10n_it_riba/tests/test_riba.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313

1414

1515
class TestInvoiceDueCost(riba_common.TestRibaCommon):
16-
def setUp(self):
17-
super(TestInvoiceDueCost, self).setUp()
18-
1916
def test_add_due_cost(self):
2017
# ---- Set Service in Company Config
2118
self.invoice.company_id.due_cost_service_id = self.service_due_cost.id

l10n_it_riba/wizard/wizard_riba_file_export.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,6 @@ class RibaFileExport(models.TransientModel):
7676
_description = "RiBa File Export Wizard"
7777
_ribaStorage = RibaStorage()
7878

79-
# @classmethod
80-
# def _build_model_attributes(cls, pool):
81-
# """ Initialize base model attributes. """
82-
# ret = super(RibaFileExport,cls)._build_model_attributes( pool)
83-
# cls.sequence = 0
84-
# cls.creditor_bank = 0
85-
# cls.sia = 0
86-
# cls.riba_date = 0
87-
# cls.support = 0
88-
# cls.riba_total = 0
89-
# cls.riba_creditor = 0
90-
# cls.riba_description = ''
91-
# cls.riba_debtor_city_province = ''
92-
9379
def _RecordIB(
9480
self,
9581
sia_creditor_bank,
@@ -307,7 +293,12 @@ def act_getfile(self):
307293
credit_cab = credit_iban[10:15]
308294
credit_account = credit_iban[-12:]
309295
if not credit_bank.codice_sia:
310-
raise UserError(_("No SIA Code specified for ") + company_name)
296+
raise UserError(
297+
_(
298+
"No SIA Code specified for %(company)s",
299+
company=company_name,
300+
)
301+
)
311302
credit_sia = credit_bank.codice_sia
312303
issued_date = datetime.datetime.now().strftime("%d%m%y")
313304
support_name = datetime.datetime.now().strftime("%d%m%y%H%M%S") + credit_sia
@@ -317,7 +308,12 @@ def act_getfile(self):
317308
not order_obj.config_id.company_id.partner_id.vat
318309
and not order_obj.config_id.company_id.partner_id.fiscalcode
319310
):
320-
raise UserError(_("No VAT or Fiscal Code specified for ") + company_name)
311+
raise UserError(
312+
_(
313+
"No VAT or Fiscal Code specified for %(company)s",
314+
company=company_name,
315+
)
316+
)
321317
array_header = [
322318
credit_sia,
323319
credit_abi,
@@ -351,7 +347,10 @@ def act_getfile(self):
351347
debit_cab = debit_iban[10:15]
352348
else:
353349
raise UserError(
354-
_("No IBAN or ABI/CAB specified for ") + line.partner_id.name
350+
_(
351+
"No IBAN or ABI/CAB specified for %(partner)s",
352+
partner=line.partner_id.name,
353+
)
355354
)
356355
debtor_city = (
357356
debtor_address.city and debtor_address.city.ljust(23)[0:23] or ""
@@ -366,7 +365,10 @@ def act_getfile(self):
366365

367366
if not line.partner_id.vat and not line.partner_id.fiscalcode:
368367
raise UserError(
369-
_("No VAT or Fiscal Code specified for ") + line.partner_id.name
368+
_(
369+
"No VAT or Fiscal Code specified for %(partner)s",
370+
partner=line.partner_id.name,
371+
)
370372
)
371373
riba = [
372374
line.sequence,

l10n_it_riba/wizard/wizard_riba_issue.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
# Copyright 2023 Simone Rubino - Aion Tech
88
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
99

10-
from odoo import _, exceptions, fields, models
10+
from odoo import _, fields, models
11+
from odoo.exceptions import UserError
1112

1213

1314
# -------------------------------------------------------
@@ -87,9 +88,11 @@ def create_rdl(
8788
if move_line.move_id.riba_partner_bank_id:
8889
bank_id = move_line.move_id.riba_partner_bank_id
8990
else:
90-
raise exceptions.Warning(
91-
_("No bank has been specified for invoice %s")
92-
% move_line.move_id.name
91+
raise UserError(
92+
_(
93+
"No bank has been specified for invoice %(invoice)s",
94+
invoice=move_line.move_id.name,
95+
)
9396
)
9497
if move_line.partner_id.group_riba and do_group_riba:
9598
for key in grouped_lines:

0 commit comments

Comments
 (0)