Skip to content

Commit e12f143

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

9 files changed

Lines changed: 58 additions & 130 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
@@ -7,7 +7,7 @@
77
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
88

99
from odoo import _, api, fields, models
10-
from odoo.exceptions import Warning as UserError
10+
from odoo.exceptions import UserError
1111

1212

1313
class AccountPaymentTerm(models.Model):
@@ -89,8 +89,8 @@ def _compute_is_past_due(self):
8989
)
9090

9191
@api.model_create_multi
92-
def create(self, vals):
93-
invoices = super().create(vals)
92+
def create(self, vals_list):
93+
invoices = super().create(vals_list)
9494
for invoice in invoices:
9595
if not invoice.riba_partner_bank_id:
9696
invoice._onchange_riba_partner_bank_id()
@@ -201,7 +201,7 @@ def action_post(self):
201201
def button_draft(self):
202202
# ---- Delete Collection Fees Line of invoice when set Back to Draft
203203
# ---- line was added on new validate
204-
res = super(AccountMove, self).button_draft()
204+
res = super().button_draft()
205205
for invoice in self:
206206
due_cost_line_ids = invoice.get_due_cost_line_ids()
207207
if due_cost_line_ids:
@@ -230,16 +230,19 @@ def button_cancel(self):
230230
if len(riba_line_ids) > 1:
231231
riba_line_ids = riba_line_ids[0]
232232
raise UserError(
233-
_("Invoice is linked to RiBa slip No. {riba}").format(
234-
riba=riba_line_ids.riba_line_id.slip_id.name
233+
_(
234+
"Invoice is linked to RiBa slip No. %(riba)s",
235+
riba=riba_line_ids.riba_line_id.slip_id.name,
235236
)
236237
)
237-
return super(AccountMove, self).button_cancel()
238+
return super().button_cancel()
238239

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

@@ -322,7 +331,7 @@ def update_paid_riba_lines(self):
322331
riba_line.slip_id.state = "paid"
323332

324333
def reconcile(self):
325-
res = super(AccountMoveLine, self).reconcile()
334+
res = super().reconcile()
326335
for line in self:
327336
line.update_paid_riba_lines()
328337
return res
@@ -371,7 +380,7 @@ def unlink(self):
371380
riba_lines = None
372381
for rec in self:
373382
riba_lines = rec.get_riba_lines()
374-
res = super(AccountFullReconcile, self).unlink()
383+
res = super().unlink()
375384
if riba_lines:
376385
self.unreconcile_riba_lines(riba_lines)
377386
return res
@@ -384,7 +393,7 @@ def unlink(self):
384393
riba_lines = None
385394
for rec in self:
386395
riba_lines = rec.get_riba_lines()
387-
res = super(AccountPartialReconcile, self).unlink()
396+
res = super().unlink()
388397
if riba_lines:
389398
self.env["account.full.reconcile"].unreconcile_riba_lines(riba_lines)
390399
return res

l10n_it_riba/models/account_config.py

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

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

l10n_it_riba/models/bank_statement.py

Lines changed: 0 additions & 83 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
@@ -9,7 +9,7 @@
99
from datetime import date
1010

1111
from odoo import _, api, fields, models
12-
from odoo.exceptions import Warning as UserError
12+
from odoo.exceptions import UserError
1313

1414

1515
class RibaList(models.Model):
@@ -140,9 +140,10 @@ def _unlink_if_not_confirmed(self):
140140
raise UserError(
141141
_(
142142
"Slip %(name)s is in state '%(state)s'. You can only delete documents"
143-
" in state 'Draft' or 'Canceled'."
143+
" in state 'Draft' or 'Canceled'.",
144+
name=riba_list.name,
145+
state=riba_list.state,
144146
)
145-
% {"name": riba_list.name, "state": riba_list.state}
146147
)
147148

148149
def confirm(self):
@@ -173,7 +174,7 @@ def _onchange_date(self):
173174
if self.date_accepted and self.date_credited:
174175
if self.date_accepted > self.date_credited:
175176
raise UserError(
176-
_("Credit date must be greater or equal to" " acceptance date.")
177+
_("Credit date must be greater or equal to acceptance date.")
177178
)
178179

179180
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
@@ -4,7 +4,7 @@
44

55
class TestRibaCommon(common.TransactionCase):
66
def setUp(self):
7-
super(TestRibaCommon, self).setUp()
7+
super().setUp()
88
tax_model = self.env["account.tax"]
99
self.account_tax = (
1010
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
@@ -12,9 +12,6 @@
1212

1313

1414
class TestInvoiceDueCost(riba_common.TestRibaCommon):
15-
def setUp(self):
16-
super(TestInvoiceDueCost, self).setUp()
17-
1815
def test_add_due_cost(self):
1916
# ---- Set Service in Company Config
2017
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
@@ -75,20 +75,6 @@ class RibaFileExport(models.TransientModel):
7575
_description = "RiBa File Export Wizard"
7676
_ribaStorage = RibaStorage()
7777

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

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

l10n_it_riba/wizard/wizard_riba_issue.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
# Copyright (C) 2012-2017 Lorenzo Battistini - Agile Business Group
77
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
88

9-
from odoo import _, exceptions, fields, models
9+
from odoo import _, fields, models
10+
from odoo.exceptions import UserError
1011

1112

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

0 commit comments

Comments
 (0)