Skip to content
Snippets Groups Projects

Add period_id in aml tree view (cf account_consult MO16-190)

Merged arthur.mayer requested to merge topic/16.0/MO16-190 into branch/16.0
4 files
+ 28
21
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -45,5 +45,4 @@
def _load_periods(self, company):
"""Build periods when loading accounting data for a new company."""
today = fields.Date.context_today(self.env.user)
@@ -49,10 +48,17 @@
today = fields.Date.context_today(self.env.user)
start_date = today.replace(month=1)
end_date = today.replace(
month=12,
)
year_str = str(end_date.year)
if self.env["account.fiscal.year"].search([("name", "=", year_str)], limit=1):
year_start = today.replace(day=1, month=1)
year_end = today.replace(day=31, month=12)
if (
self.env["account.fiscal.year"]
.sudo()
.search(
[
("company_id", "=", company.id),
("date_from", "<=", year_start),
("date_to", ">=", year_end),
],
limit=1,
)
):
return # Fiscal year already exists in this company.
@@ -57,5 +63,5 @@
return # Fiscal year already exists in this company.
fiscal_year_record = self.env["account.fiscal.year"].create(
self.env["account.fiscal.year"].sudo().create(
{
"company_id": company.id,
@@ -60,6 +66,6 @@
{
"company_id": company.id,
"date_from": start_date,
"date_to": end_date,
"name": year_str,
"date_from": year_start,
"date_to": year_end,
"name": str(today.year),
}
@@ -65,6 +71,5 @@
}
)
fiscal_year_record.create_periods()
).create_periods()
# In demo mode, also load periods for the 2017 year. Used by tests in
# this module and also some Odoo ones, especially "account_facturx".
@@ -72,6 +77,6 @@
[("name", "=", "account_period")]
)
if this_module and this_module.demo:
self.env["account.fiscal.year"].create(
self.env["account.fiscal.year"].sudo().create(
{
"company_id": company.id,
@@ -76,7 +81,7 @@
{
"company_id": company.id,
"date_from": start_date.replace(year=2017),
"date_to": end_date.replace(year=2017),
"date_from": year_start.replace(year=2017),
"date_to": year_end.replace(year=2017),
"name": "2017",
}
).create_periods()
Loading