Browse Source

no more fiscal period, no more root account

pull/189/head
Adrien Peiffer (ACSONE) 9 years ago
committed by Stéphane Bidoul
parent
commit
cebd88244a
  1. 60
      mis_builder/models/mis_builder.py
  2. 3
      mis_builder/views/mis_builder.xml

60
mis_builder/models/mis_builder.py

@ -304,8 +304,6 @@ class MisReportInstancePeriod(models.Model):
def _compute_dates(self):
self.date_from = False
self.date_to = False
self.period_from = False
self.period_to = False
self.valid = False
d = fields.Date.from_string(self.report_instance_id.pivot_date)
if self.type == 'd':
@ -323,28 +321,6 @@ class MisReportInstancePeriod(models.Model):
self.date_from = fields.Date.to_string(date_from)
self.date_to = fields.Date.to_string(date_to)
self.valid = True
elif self.type == 'fp':
current_periods = self.env['account.period'].search(
[('special', '=', False),
('date_start', '<=', d),
('date_stop', '>=', d),
('company_id', '=',
self.report_instance_id.company_id.id)])
if current_periods:
all_periods = self.env['account.period'].search(
[('special', '=', False),
('company_id', '=',
self.report_instance_id.company_id.id)],
order='date_start')
all_period_ids = [p.id for p in all_periods]
p = all_period_ids.index(current_periods[0].id) + self.offset
if p >= 0 and p + self.duration <= len(all_period_ids):
periods = all_periods[p:p + self.duration]
self.date_from = periods[0].date_start
self.date_to = periods[-1].date_stop
self.period_from = periods[0]
self.period_to = periods[-1]
self.valid = True
_name = 'mis.report.instance.period'
@ -352,7 +328,6 @@ class MisReportInstancePeriod(models.Model):
string='Description', translate=True)
type = fields.Selection([('d', _('Day')),
('w', _('Week')),
('fp', _('Fiscal Period')),
# ('fy', _('Fiscal Year'))
],
required=True,
@ -365,12 +340,6 @@ class MisReportInstancePeriod(models.Model):
default=1)
date_from = fields.Date(compute='_compute_dates', string="From")
date_to = fields.Date(compute='_compute_dates', string="To")
period_from = fields.Many2one(compute='_compute_dates',
comodel_name='account.period',
string="From period")
period_to = fields.Many2one(compute='_compute_dates',
comodel_name='account.period',
string="To period")
valid = fields.Boolean(compute='_compute_dates',
type='boolean',
string='Valid')
@ -434,11 +403,10 @@ class MisReportInstancePeriod(models.Model):
if AEP.has_account_var(expr):
aep = AEP(self.env)
aep.parse_expr(expr)
aep.done_parsing(self.report_instance_id.root_account)
aep.done_parsing()
domain = aep.get_aml_domain_for_expr(
expr,
self.date_from, self.date_to,
self.period_from, self.period_to,
self.report_instance_id.target_move)
domain.extend(self._get_additional_move_line_filter())
return {
@ -523,7 +491,6 @@ class MisReportInstancePeriod(models.Model):
localdict.update(self._fetch_queries())
aep.do_queries(self.date_from, self.date_to,
self.period_from, self.period_to,
self.report_instance_id.target_move,
self._get_additional_move_line_filter())
@ -628,14 +595,7 @@ class MisReportInstance(models.Model):
required=True,
default='posted')
company_id = fields.Many2one(comodel_name='res.company',
string='Company',
readonly=True,
related='root_account.company_id',
store=True)
root_account = fields.Many2one(comodel_name='account.account',
domain='[("parent_id", "=", False)]',
string="Account chart",
required=True)
string='Company')
landscape_pdf = fields.Boolean(string='Landscape PDF')
def _format_date(self, lang_id, date):
@ -667,7 +627,7 @@ class MisReportInstance(models.Model):
aep = AEP(self.env)
for kpi in self.report_id.kpi_ids:
aep.parse_expr(kpi.expression)
aep.done_parsing(self.root_account)
aep.done_parsing()
# fetch user language only once
# TODO: is this necessary?
@ -707,19 +667,11 @@ class MisReportInstance(models.Model):
# add the column header
if period.duration > 1 or period.type == 'w':
# from, to
if period.period_from and period.period_to:
date_from = period.period_from.name
date_to = period.period_to.name
else:
date_from = self._format_date(lang_id, period.date_from)
date_to = self._format_date(lang_id, period.date_to)
date_from = self._format_date(lang_id, period.date_from)
date_to = self._format_date(lang_id, period.date_to)
header_date = _('from %s to %s') % (date_from, date_to)
else:
# one period or one day
if period.period_from and period.period_to:
header_date = period.period_from.name
else:
header_date = self._format_date(lang_id, period.date_from)
header_date = self._format_date(lang_id, period.date_from)
header[0]['cols'].append(dict(name=period.name, date=header_date))
# add kpi values
kpi_values = kpi_values_by_period_ids[period.id]

3
mis_builder/views/mis_builder.xml

@ -169,7 +169,6 @@
<field name="report_id" colspan="4"/>
<field name="description"/>
<field name="landscape_pdf" />
<field name="root_account"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="date"/>
<field name="target_move"/>
@ -183,8 +182,6 @@
<field name="normalize_factor"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="period_from"/>
<field name="period_to"/>
<field name="valid" invisible="1"/>
<field name="report_instance_id" invisible="1"/>
<field name="id" invisible="1"/>

Loading…
Cancel
Save