Skip to content

Commit 96d0326

Browse files
committed
[MIG] account_fiscal_year_closing: Migration to 18.0
1 parent 6dad008 commit 96d0326

11 files changed

+68
-161
lines changed

account_fiscal_year_closing/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Fiscal year closing",
66
"summary": "Generic fiscal year closing wizard",
7-
"version": "16.0.1.0.0",
7+
"version": "18.0.1.0.0",
88
"category": "Accounting & Finance",
99
"website": "https://github.com/OCA/account-closing",
1010
"author": "Odoo Community Association (OCA)",

account_fiscal_year_closing/migrations/16.0.1.0.0/noupdate_changes.xml

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

account_fiscal_year_closing/migrations/16.0.1.0.0/post-migration.py

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

account_fiscal_year_closing/migrations/16.0.1.0.0/pre-migration.py

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

account_fiscal_year_closing/models/account_fiscalyear_closing.py

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from dateutil.relativedelta import relativedelta
66

7-
from odoo import _, api, exceptions, fields, models
7+
from odoo import api, exceptions, fields, models
88
from odoo.exceptions import ValidationError
99
from odoo.tools import float_is_zero
1010

@@ -32,28 +32,22 @@ def _default_company_id(self):
3232

3333
name = fields.Char(
3434
readonly=True,
35-
states={"draft": [("readonly", False)]},
3635
)
3736
check_draft_moves = fields.Boolean(
3837
readonly=True,
39-
states={"draft": [("readonly", False)]},
4038
)
4139
year = fields.Integer(
4240
help="Introduce here the year to close. If the fiscal year is between "
4341
"several natural years, you have to put here the last one.",
4442
default=lambda self: self._default_year(),
4543
readonly=True,
46-
states={"draft": [("readonly", False)]},
4744
)
4845
company_id = fields.Many2one(
4946
default=lambda self: self._default_company_id(),
5047
readonly=True,
51-
states={"draft": [("readonly", False)]},
5248
)
53-
chart_template_id = fields.Many2one(
54-
comodel_name="account.chart.template",
55-
string="Chart template",
56-
related="company_id.chart_template_id",
49+
chart_template = fields.Selection(
50+
related="company_id.chart_template",
5751
readonly=True,
5852
)
5953
state = fields.Selection(
@@ -74,33 +68,28 @@ def _default_company_id(self):
7468
string="From date",
7569
required=True,
7670
readonly=True,
77-
states={"draft": [("readonly", False)]},
7871
)
7972
date_end = fields.Date(
8073
string="To date",
8174
required=True,
8275
readonly=True,
83-
states={"draft": [("readonly", False)]},
8476
)
8577
date_opening = fields.Date(
8678
string="Opening date",
8779
required=True,
8880
readonly=True,
89-
states={"draft": [("readonly", False)]},
9081
)
9182
closing_template_id = fields.Many2one(
9283
comodel_name="account.fiscalyear.closing.template",
9384
string="Closing template",
94-
domain="[('chart_template_ids', '=', chart_template_id)]",
85+
domain="[('chart_template', '=', chart_template)]",
9586
readonly=True,
96-
states={"draft": [("readonly", False)]},
9787
)
9888
move_config_ids = fields.One2many(
9989
comodel_name="account.fiscalyear.closing.config",
10090
inverse_name="fyc_id",
10191
string="Moves configuration",
10292
readonly=True,
103-
states={"draft": [("readonly", False)]},
10493
)
10594
move_ids = fields.One2many(
10695
comodel_name="account.move",
@@ -113,7 +102,7 @@ def _default_company_id(self):
113102
(
114103
"year_company_uniq",
115104
"unique(year, company_id)",
116-
_(
105+
(
117106
"There should be only one fiscal year closing for that year and "
118107
"company!"
119108
),
@@ -135,7 +124,7 @@ def _prepare_mapping(self, tmpl_mapping):
135124
)
136125
# Use an error name if no destination account found
137126
if not dest_account:
138-
name = _("No destination account '%s' found.") % (
127+
name = self.env._("No destination account '%s' found.") % (
139128
tmpl_mapping.dest_account,
140129
)
141130
return {
@@ -233,9 +222,12 @@ def draft_moves_check(self):
233222
]
234223
)
235224
if draft_moves:
236-
msg = _("One or more draft moves found: \n")
225+
msg = closing.env._("One or more draft moves found: \n")
237226
for move in draft_moves:
238-
msg += f"ID: {move.id}, Date: {move.date}, Number: {move.name}, Ref: {move.ref}\n"
227+
msg += (
228+
f"ID: {move.id}, Date: {move.date}"
229+
f", Number: {move.name}, Ref: {move.ref}\n"
230+
)
239231
raise ValidationError(msg)
240232
return True
241233

@@ -252,7 +244,7 @@ def _show_unbalanced_move_wizard(self, data):
252244
wizard = self.env["account.fiscalyear.closing.unbalanced.move"].create(data)
253245
return {
254246
"type": "ir.actions.act_window",
255-
"name": _("Unbalanced journal entry found"),
247+
"name": self.env._("Unbalanced journal entry found"),
256248
"view_type": "form",
257249
"view_mode": "form",
258250
"res_model": "account.fiscalyear.closing.unbalanced.move",
@@ -311,20 +303,20 @@ def button_post(self):
311303
def button_open_moves(self):
312304
# Return an action for showing moves
313305
return {
314-
"name": _("Fiscal closing moves"),
306+
"name": self.env._("Fiscal closing moves"),
315307
"type": "ir.actions.act_window",
316308
"view_type": "form",
317-
"view_mode": "tree,form",
309+
"view_mode": "list,form",
318310
"res_model": "account.move",
319311
"domain": [("fyc_id", "in", self.ids)],
320312
}
321313

322314
def button_open_move_lines(self):
323315
return {
324-
"name": _("Fiscal closing move lines"),
316+
"name": self.env._("Fiscal closing move lines"),
325317
"type": "ir.actions.act_window",
326318
"view_type": "form",
327-
"view_mode": "tree,form",
319+
"view_mode": "list,form",
328320
"res_model": "account.move.line",
329321
"domain": [("move_id.fyc_id", "in", self.ids)],
330322
}
@@ -346,12 +338,12 @@ def button_recover(self):
346338
def unlink(self):
347339
if any(x.state not in ("draft", "cancelled") for x in self):
348340
raise exceptions.UserError(
349-
_(
341+
self.env._(
350342
"You can't remove any closing that is not in draft or "
351343
"cancelled state."
352344
)
353345
)
354-
return super(AccountFiscalyearClosing, self).unlink()
346+
return super().unlink()
355347

356348

357349
class AccountFiscalyearClosingConfig(models.Model):
@@ -387,7 +379,7 @@ class AccountFiscalyearClosingConfig(models.Model):
387379
(
388380
"code_uniq",
389381
"unique(code, fyc_id)",
390-
_("Code must be unique per fiscal year closing!"),
382+
"Code must be unique per fiscal year closing!",
391383
),
392384
]
393385

@@ -436,7 +428,7 @@ def _mapping_move_lines_get(self):
436428
dest_totals.setdefault(dest, 0)
437429
src_accounts = self.env["account.account"].search(
438430
[
439-
("company_id", "=", self.fyc_id.company_id.id),
431+
("company_ids", "in", self.fyc_id.company_id.ids),
440432
("code", "=ilike", account_map.src_accounts),
441433
],
442434
order="code ASC",
@@ -550,15 +542,15 @@ def create(self, vals_list):
550542
vals["dest_account_id"], list
551543
):
552544
vals["dest_account_id"] = vals["dest_account_id"][0]
553-
res = super(AccountFiscalyearClosingMapping, self).create(vals_list)
545+
res = super().create(vals_list)
554546
return res
555547

556548
def write(self, vals):
557549
if vals.get("dest_account_id", False) and isinstance(
558550
vals["dest_account_id"], list
559551
):
560552
vals["dest_account_id"] = vals["dest_account_id"][0]
561-
res = super(AccountFiscalyearClosingMapping, self).write(vals)
553+
res = super().write(vals)
562554
return res
563555

564556
def dest_move_line_prepare(self, dest, balance, partner_id=False):
@@ -573,7 +565,7 @@ def dest_move_line_prepare(self, dest, balance, partner_id=False):
573565
"account_id": dest.id,
574566
"debit": balance < 0 and -balance,
575567
"credit": balance > 0 and balance,
576-
"name": _("Result"),
568+
"name": self.env._("Result"),
577569
"date": date,
578570
"partner_id": partner_id,
579571
}

account_fiscal_year_closing/models/account_fiscalyear_closing_template.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ class AccountFiscalyearClosingTemplate(models.Model):
1414
inverse_name="template_id",
1515
string="Moves configuration",
1616
)
17-
chart_template_ids = fields.Many2many(
18-
comodel_name="account.chart.template",
17+
chart_template = fields.Selection(
1918
string="Available for",
19+
selection=lambda self: self.env[
20+
"account.chart.template"
21+
]._select_chart_template(),
2022
required=True,
2123
)
2224

account_fiscal_year_closing/models/account_move.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
22

3-
from odoo import _, fields, models
3+
from odoo import fields, models
44

55

66
class AccountMove(models.Model):
@@ -15,7 +15,7 @@ def _selection_closing_type(self):
1515
allfields=["move_type"]
1616
)["move_type"]["selection"]
1717
)
18-
res.append(("none", _("None")))
18+
res.append(("none", self.env._("None")))
1919
return res
2020

2121
fyc_id = fields.Many2one(
@@ -27,5 +27,4 @@ def _selection_closing_type(self):
2727
closing_type = fields.Selection(
2828
selection=_selection_closing_type,
2929
default="none",
30-
states={"posted": [("readonly", True)]},
3130
)

account_fiscal_year_closing/tests/test_account_fiscal_year_closing.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
1111

1212

13-
@tagged("post_install")
13+
@tagged("post_install_l10n", "post_install", "-at_install")
1414
class TestAccountFiscalYearClosing(AccountTestInvoicingCommon):
1515
@classmethod
1616
def setUpClass(cls, chart_template_ref=None):
@@ -105,16 +105,18 @@ def setUpClass(cls, chart_template_ref=None):
105105
{
106106
"value": "percent",
107107
"value_amount": 50,
108-
"days": 15,
108+
"delay_type": "days_after",
109+
"nb_days": 15,
109110
},
110111
),
111112
(
112113
0,
113114
0,
114115
{
115-
"value": "balance",
116-
"days_after": 15,
117-
"end_month": True,
116+
"value": "percent",
117+
"value_amount": 50,
118+
"delay_type": "days_after_end_of_month",
119+
"nb_days": 15,
118120
},
119121
),
120122
],

0 commit comments

Comments
 (0)