Skip to content

Commit 772b6d2

Browse files
committed
[IMP] assets_management: black, isort, prettier
1 parent d451041 commit 772b6d2

59 files changed

Lines changed: 5634 additions & 4690 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

assets_management/__manifest__.py

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,50 @@
33
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
44

55
{
6-
'name': 'ITA - Gestione Cespiti',
7-
'version': '12.0.1.0.0',
8-
'category': 'Localization/Italy',
9-
'summary': "Gestione Cespiti",
10-
'author': 'Openforce, Odoo Community Association (OCA)',
11-
'website': 'https://github.com/OCA/l10n-italy'
12-
'/tree/12.0/assets_management',
13-
'license': 'AGPL-3',
14-
'depends': [
15-
'account',
16-
'account_cancel',
17-
'account_financial_report',
18-
'account_fiscal_year',
19-
'mail',
6+
"name": "ITA - Gestione Cespiti",
7+
"version": "12.0.1.0.0",
8+
"category": "Localization/Italy",
9+
"summary": "Gestione Cespiti",
10+
"author": "Openforce, Odoo Community Association (OCA)",
11+
"website": "https://github.com/OCA/l10n-italy" "/tree/12.0/assets_management",
12+
"license": "AGPL-3",
13+
"depends": [
14+
"account",
15+
"account_cancel",
16+
"account_financial_report",
17+
"account_fiscal_year",
18+
"mail",
2019
],
21-
'data': [
22-
'security/ir.model.access.csv',
23-
'security/res_groups.xml',
24-
'security/rules.xml',
25-
'data/ir_cron.xml',
26-
'data/asset_data.xml',
27-
'report/layout.xml',
28-
'report/paperformat.xml',
29-
'report/templates/asset_journal.xml',
30-
'report/templates/asset_previsional.xml',
31-
'report/reports.xml',
32-
'views/action_client.xml',
33-
'views/asset_menuitems.xml',
34-
'views/account_invoice.xml',
35-
'views/account_move.xml',
36-
'views/asset.xml',
37-
'views/asset_accounting_info.xml',
38-
'views/asset_category.xml',
39-
'views/asset_depreciation.xml',
40-
'views/asset_depreciation_line.xml',
41-
'views/asset_depreciation_line_type.xml',
42-
'views/asset_depreciation_mode.xml',
43-
'views/asset_depreciation_type.xml',
44-
'views/asset_tag.xml',
45-
'wizard/account_invoice_manage_asset_view.xml',
46-
'wizard/account_move_manage_asset_view.xml',
47-
'wizard/asset_generate_depreciation_view.xml',
48-
'wizard/asset_journal_report_view.xml',
49-
'wizard/asset_previsional_report_view.xml',
20+
"data": [
21+
"security/ir.model.access.csv",
22+
"security/res_groups.xml",
23+
"security/rules.xml",
24+
"data/ir_cron.xml",
25+
"data/asset_data.xml",
26+
"report/layout.xml",
27+
"report/paperformat.xml",
28+
"report/templates/asset_journal.xml",
29+
"report/templates/asset_previsional.xml",
30+
"report/reports.xml",
31+
"views/action_client.xml",
32+
"views/asset_menuitems.xml",
33+
"views/account_invoice.xml",
34+
"views/account_move.xml",
35+
"views/asset.xml",
36+
"views/asset_accounting_info.xml",
37+
"views/asset_category.xml",
38+
"views/asset_depreciation.xml",
39+
"views/asset_depreciation_line.xml",
40+
"views/asset_depreciation_line_type.xml",
41+
"views/asset_depreciation_mode.xml",
42+
"views/asset_depreciation_type.xml",
43+
"views/asset_tag.xml",
44+
"wizard/account_invoice_manage_asset_view.xml",
45+
"wizard/account_move_manage_asset_view.xml",
46+
"wizard/asset_generate_depreciation_view.xml",
47+
"wizard/asset_journal_report_view.xml",
48+
"wizard/asset_previsional_report_view.xml",
5049
],
51-
'development_status': 'Beta',
52-
'installable': True,
50+
"development_status": "Beta",
51+
"installable": True,
5352
}

assets_management/data/asset_data.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo noupdate="0">
33

44
<!-- Natura ammortamento -->
@@ -36,7 +36,7 @@
3636
<field name="used_asset_coeff">1</field>
3737
</record>
3838
<record id="ad_mode_materiale_line" model="asset.depreciation.mode.line">
39-
<field name="mode_id" ref="ad_mode_materiale"/>
39+
<field name="mode_id" ref="ad_mode_materiale" />
4040
<field name="from_nr">1</field>
4141
<field name="to_nr">1</field>
4242
<field name="coefficient">0.5</field>

assets_management/data/ir_cron.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo noupdate="1">
33

44
<record id="clean_asset_accounting_info_cron" model="ir.cron">
55
<field name="name">Vacuum Empty Asset Accounting Info</field>
6-
<field name="active" eval="False"/>
7-
<field name="user_id" ref="base.user_root"/>
6+
<field name="active" eval="False" />
7+
<field name="user_id" ref="base.user_root" />
88
<field name="interval_number">5</field>
99
<field name="interval_type">minutes</field>
1010
<field name="numbercall">-1</field>
11-
<field name="doall" eval="True"/>
12-
<field name="model_id" ref="model_asset_accounting_info"/>
11+
<field name="doall" eval="True" />
12+
<field name="model_id" ref="model_asset_accounting_info" />
1313
<field name="state">code</field>
1414
<field name="code">model.cron_vacuum_table()</field>
1515
</record>

assets_management/models/account_account.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,31 @@
77

88

99
class AccountAccount(models.Model):
10-
_inherit = 'account.account'
10+
_inherit = "account.account"
1111

1212
@api.multi
1313
def unlink(self):
14-
if self.env['asset.category'].sudo().search([
15-
'|',
16-
'|',
17-
'|',
18-
'|',
19-
('asset_account_id', 'in', self.ids),
20-
('depreciation_account_id', 'in', self.ids),
21-
('fund_account_id', 'in', self.ids),
22-
('gain_account_id', 'in', self.ids),
23-
('loss_account_id', 'in', self.ids),
24-
]):
14+
if (
15+
self.env["asset.category"]
16+
.sudo()
17+
.search(
18+
[
19+
"|",
20+
"|",
21+
"|",
22+
"|",
23+
("asset_account_id", "in", self.ids),
24+
("depreciation_account_id", "in", self.ids),
25+
("fund_account_id", "in", self.ids),
26+
("gain_account_id", "in", self.ids),
27+
("loss_account_id", "in", self.ids),
28+
]
29+
)
30+
):
2531
raise UserError(
26-
_("Cannot delete accounts while they're still used"
27-
" by asset categories.")
32+
_(
33+
"Cannot delete accounts while they're still used"
34+
" by asset categories."
35+
)
2836
)
2937
return super().unlink()

assets_management/models/account_fiscal_year.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77

88

99
class AccountFiscalYear(models.Model):
10-
_inherit = 'account.fiscal.year'
10+
_inherit = "account.fiscal.year"
1111

1212
@api.model
13-
def get_fiscal_year_by_date(
14-
self, date, limit=1, company=None, miss_raise=True
15-
):
13+
def get_fiscal_year_by_date(self, date, limit=1, company=None, miss_raise=True):
1614
"""
1715
Retrieves fiscal year by given ``date`` (a datetime.date object).
1816
@@ -33,7 +31,7 @@ def get_fiscal_year_by_date_domain(self, date, company=None):
3331
"""
3432
Prepares a search() domain to retrieve fiscal years by given ``date``.
3533
"""
36-
domain = [('date_from', '<=', date), ('date_to', '>=', date)]
34+
domain = [("date_from", "<=", date), ("date_to", ">=", date)]
3735
if company:
38-
domain.append(('company_id', 'in', company.ids))
36+
domain.append(("company_id", "in", company.ids))
3937
return domain

assets_management/models/account_invoice.py

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,39 @@
77

88

99
class AccountInvoice(models.Model):
10-
_inherit = 'account.invoice'
10+
_inherit = "account.invoice"
1111

1212
asset_accounting_info_ids = fields.One2many(
13-
'asset.accounting.info',
14-
'invoice_id',
15-
string="Assets Accounting Info"
13+
"asset.accounting.info", "invoice_id", string="Assets Accounting Info"
1614
)
1715

1816
asset_ids = fields.Many2many(
19-
'asset.asset',
20-
compute='_compute_asset_data',
21-
store=True,
22-
string="Assets"
17+
"asset.asset", compute="_compute_asset_data", store=True, string="Assets"
2318
)
2419

2520
dep_line_ids = fields.Many2many(
26-
'asset.depreciation.line',
27-
compute='_compute_asset_data',
21+
"asset.depreciation.line",
22+
compute="_compute_asset_data",
2823
store=True,
29-
string="Depreciation Lines"
24+
string="Depreciation Lines",
3025
)
3126

3227
hide_link_asset_button = fields.Boolean(
33-
compute='_compute_hide_link_asset_button',
28+
compute="_compute_hide_link_asset_button",
3429
default=True,
3530
string="Hide Asset Button",
3631
)
3732

38-
@api.constrains('company_id')
33+
@api.constrains("company_id")
3934
def check_company(self):
4035
for inv in self:
41-
comp = inv.get_linked_aa_info_records().mapped('company_id')
36+
comp = inv.get_linked_aa_info_records().mapped("company_id")
4237
if len(comp) > 1 or (comp and comp != inv.company_id):
4338
raise ValidationError(
44-
_("`{}`: cannot change invoice's company once it's already"
45-
" related to an asset.")
46-
.format(inv.name_get()[0][-1])
39+
_(
40+
"`{}`: cannot change invoice's company once it's already"
41+
" related to an asset."
42+
).format(inv.name_get()[0][-1])
4743
)
4844

4945
@api.multi
@@ -53,43 +49,45 @@ def action_invoice_cancel(self):
5349
# Remove every a.a.info related to current invoices, and delete
5450
# related depreciation lines
5551
aa_infos = self.mapped(lambda i: i.get_linked_aa_info_records())
56-
dep_lines = aa_infos.mapped('dep_line_id')
52+
dep_lines = aa_infos.mapped("dep_line_id")
5753
aa_infos.unlink()
5854
# Filtering needed: cannot delete dep lines with a.a.info
59-
dep_lines.filtered(
60-
lambda l: not l.asset_accounting_info_ids
61-
).unlink()
55+
dep_lines.filtered(lambda l: not l.asset_accounting_info_ids).unlink()
6256
return res
6357

6458
@api.multi
6559
@api.depends(
66-
'asset_accounting_info_ids',
67-
'asset_accounting_info_ids.asset_id',
68-
'asset_accounting_info_ids.dep_line_id',
60+
"asset_accounting_info_ids",
61+
"asset_accounting_info_ids.asset_id",
62+
"asset_accounting_info_ids.dep_line_id",
6963
)
7064
def _compute_asset_data(self):
7165
for inv in self:
7266
aa_info = inv.get_linked_aa_info_records()
73-
assets = aa_info.mapped('asset_id')
74-
dep_lines = aa_info.mapped('dep_line_id')
67+
assets = aa_info.mapped("asset_id")
68+
dep_lines = aa_info.mapped("dep_line_id")
7569
if dep_lines:
76-
assets += dep_lines.mapped('asset_id')
77-
inv.update({
78-
'asset_ids': [(6, 0, assets.ids)],
79-
'dep_line_ids': [(6, 0, dep_lines.ids)]
80-
})
70+
assets += dep_lines.mapped("asset_id")
71+
inv.update(
72+
{
73+
"asset_ids": [(6, 0, assets.ids)],
74+
"dep_line_ids": [(6, 0, dep_lines.ids)],
75+
}
76+
)
8177

8278
@api.multi
8379
def _compute_hide_link_asset_button(self):
8480
valid_account_ids = self.get_valid_accounts()
8581
if not valid_account_ids:
86-
self.update({'hide_link_asset_button': True})
82+
self.update({"hide_link_asset_button": True})
8783
else:
8884
for inv in self:
89-
inv.hide_link_asset_button = not any([
90-
l.account_id.id in valid_account_ids.ids
91-
for l in inv.invoice_line_ids
92-
]) or inv.state in ('draft', 'cancel')
85+
inv.hide_link_asset_button = not any(
86+
[
87+
l.account_id.id in valid_account_ids.ids
88+
for l in inv.invoice_line_ids
89+
]
90+
) or inv.state in ("draft", "cancel")
9391

9492
@api.multi
9593
def open_wizard_manage_asset(self):
@@ -98,31 +96,33 @@ def open_wizard_manage_asset(self):
9896
lambda l: not l.asset_accounting_info_ids
9997
)
10098
if not lines:
101-
raise ValidationError(
102-
_("Every line is already linked to an asset.")
103-
)
99+
raise ValidationError(_("Every line is already linked to an asset."))
104100

105-
xmlid = 'assets_management.action_wizard_invoice_manage_asset'
101+
xmlid = "assets_management.action_wizard_invoice_manage_asset"
106102
act = self.env.ref(xmlid).read()[0]
107103
ctx = dict(self._context)
108-
ctx.update({
109-
'default_company_id': self.company_id.id,
110-
'default_dismiss_date': self.date_invoice or self.date_due,
111-
'default_invoice_ids': [(6, 0, self.ids)],
112-
'default_invoice_line_ids': [(6, 0, lines.ids)],
113-
'default_purchase_date': self.date_invoice or self.date_due,
114-
'invoice_ids': self.ids,
115-
})
116-
act.update({'context': ctx})
104+
ctx.update(
105+
{
106+
"default_company_id": self.company_id.id,
107+
"default_dismiss_date": self.date_invoice or self.date_due,
108+
"default_invoice_ids": [(6, 0, self.ids)],
109+
"default_invoice_line_ids": [(6, 0, lines.ids)],
110+
"default_purchase_date": self.date_invoice or self.date_due,
111+
"invoice_ids": self.ids,
112+
}
113+
)
114+
act.update({"context": ctx})
117115
return act
118116

119117
def get_linked_aa_info_records(self):
120118
self.ensure_one()
121-
return self.env['asset.accounting.info'].search([
122-
'|',
123-
('invoice_id', '=', self.id),
124-
('invoice_line_id.invoice_id', '=', self.id),
125-
])
119+
return self.env["asset.accounting.info"].search(
120+
[
121+
"|",
122+
("invoice_id", "=", self.id),
123+
("invoice_line_id.invoice_id", "=", self.id),
124+
]
125+
)
126126

127127
def get_valid_accounts(self):
128-
return self.env['asset.category'].search([]).mapped('asset_account_id')
128+
return self.env["asset.category"].search([]).mapped("asset_account_id")

0 commit comments

Comments
 (0)