[IMP] improve report view
parent
55207c194e
commit
4505af107d
|
@ -659,13 +659,23 @@ class MisReportInstancePeriod(models.Model):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@api.one
|
@api.one
|
||||||
@api.depends('report_instance_id.pivot_date', 'type', 'offset', 'duration')
|
@api.depends('report_instance_id.pivot_date', 'type', 'offset',
|
||||||
|
'duration', 'report_instance_id.comparison_mode')
|
||||||
def _compute_dates(self):
|
def _compute_dates(self):
|
||||||
self.date_from = False
|
self.date_from = False
|
||||||
self.date_to = False
|
self.date_to = False
|
||||||
self.valid = False
|
self.valid = False
|
||||||
d = fields.Date.from_string(self.report_instance_id.pivot_date)
|
report = self.report_instance_id
|
||||||
if self.type == 'd':
|
d = fields.Date.from_string(report.pivot_date)
|
||||||
|
if not report.comparison_mode:
|
||||||
|
self.date_from = report.date_from
|
||||||
|
self.date_to = report.date_to
|
||||||
|
self.valid = True
|
||||||
|
elif self.mode == 'fix':
|
||||||
|
self.date_from = self.manual_date_from
|
||||||
|
self.date_to = self.manual_date_to
|
||||||
|
self.valid = True
|
||||||
|
elif self.type == 'd':
|
||||||
date_from = d + datetime.timedelta(days=self.offset)
|
date_from = d + datetime.timedelta(days=self.offset)
|
||||||
date_to = date_from + \
|
date_to = date_from + \
|
||||||
datetime.timedelta(days=self.duration - 1)
|
datetime.timedelta(days=self.duration - 1)
|
||||||
|
@ -705,6 +715,10 @@ class MisReportInstancePeriod(models.Model):
|
||||||
|
|
||||||
name = fields.Char(size=32, required=True,
|
name = fields.Char(size=32, required=True,
|
||||||
string='Description', translate=True)
|
string='Description', translate=True)
|
||||||
|
mode = fields.Selection([('fix', 'Fix'),
|
||||||
|
('relative', 'Relative'),
|
||||||
|
], required=True,
|
||||||
|
default='fix')
|
||||||
type = fields.Selection([('d', _('Day')),
|
type = fields.Selection([('d', _('Day')),
|
||||||
('w', _('Week')),
|
('w', _('Week')),
|
||||||
('date_range', _('Date Range'))
|
('date_range', _('Date Range'))
|
||||||
|
@ -721,6 +735,11 @@ class MisReportInstancePeriod(models.Model):
|
||||||
default=1)
|
default=1)
|
||||||
date_from = fields.Date(compute='_compute_dates', string="From")
|
date_from = fields.Date(compute='_compute_dates', string="From")
|
||||||
date_to = fields.Date(compute='_compute_dates', string="To")
|
date_to = fields.Date(compute='_compute_dates', string="To")
|
||||||
|
manual_date_from = fields.Date(string="From")
|
||||||
|
manual_date_to = fields.Date(string="To")
|
||||||
|
date_range_id = fields.Many2one(
|
||||||
|
comodel_name='date.range',
|
||||||
|
string='Date Range')
|
||||||
valid = fields.Boolean(compute='_compute_dates',
|
valid = fields.Boolean(compute='_compute_dates',
|
||||||
type='boolean',
|
type='boolean',
|
||||||
string='Valid')
|
string='Valid')
|
||||||
|
@ -740,7 +759,7 @@ class MisReportInstancePeriod(models.Model):
|
||||||
default=1)
|
default=1)
|
||||||
subkpi_ids = fields.Many2many(
|
subkpi_ids = fields.Many2many(
|
||||||
'mis.report.subkpi',
|
'mis.report.subkpi',
|
||||||
string="Sub KPI")
|
string="Sub KPI Filter")
|
||||||
|
|
||||||
_order = 'sequence, id'
|
_order = 'sequence, id'
|
||||||
|
|
||||||
|
@ -753,6 +772,12 @@ class MisReportInstancePeriod(models.Model):
|
||||||
'Period name should be unique by report'),
|
'Period name should be unique by report'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@api.onchange('date_range_id')
|
||||||
|
def onchange_date_range(self):
|
||||||
|
for record in self:
|
||||||
|
record.manual_date_from = record.date_range_id.date_start
|
||||||
|
record.manual_date_to = record.date_range_id.date_end
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _get_additional_move_line_filter(self):
|
def _get_additional_move_line_filter(self):
|
||||||
""" Prepare a filter to apply on all move lines
|
""" Prepare a filter to apply on all move lines
|
||||||
|
@ -944,6 +969,14 @@ class MisReportInstance(models.Model):
|
||||||
default=_default_company,
|
default=_default_company,
|
||||||
required=True)
|
required=True)
|
||||||
landscape_pdf = fields.Boolean(string='Landscape PDF')
|
landscape_pdf = fields.Boolean(string='Landscape PDF')
|
||||||
|
comparison_mode = fields.Boolean(
|
||||||
|
compute="_compute_comparison_mode",
|
||||||
|
inverse="_inverse_comparison_mode")
|
||||||
|
date_range_id = fields.Many2one(
|
||||||
|
comodel_name='date.range',
|
||||||
|
string='Date Range')
|
||||||
|
date_from = fields.Date(string="From")
|
||||||
|
date_to = fields.Date(string="To")
|
||||||
|
|
||||||
@api.one
|
@api.one
|
||||||
def copy(self, default=None):
|
def copy(self, default=None):
|
||||||
|
@ -957,6 +990,37 @@ class MisReportInstance(models.Model):
|
||||||
return datetime.datetime.strftime(
|
return datetime.datetime.strftime(
|
||||||
fields.Date.from_string(date), date_format)
|
fields.Date.from_string(date), date_format)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.depends('date_from')
|
||||||
|
def _compute_comparison_mode(self):
|
||||||
|
for instance in self:
|
||||||
|
instance.advanced_mode = not bool(instance.date_from)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def _inverse_comparison_mode(self):
|
||||||
|
for record in self:
|
||||||
|
if not record.comparison_mode:
|
||||||
|
if not record.date_from:
|
||||||
|
record.date_from = datetime.now()
|
||||||
|
if not record.date_to:
|
||||||
|
record.date_to = datetime.now()
|
||||||
|
record.period_ids.unlink()
|
||||||
|
record.write({'period_ids': [
|
||||||
|
(0, 0, {
|
||||||
|
'name': 'Default',
|
||||||
|
'type': 'd',
|
||||||
|
})
|
||||||
|
]})
|
||||||
|
else:
|
||||||
|
record.date_from = None
|
||||||
|
record.date_to = None
|
||||||
|
|
||||||
|
@api.onchange('date_range_id')
|
||||||
|
def onchange_date_range(self):
|
||||||
|
for record in self:
|
||||||
|
record.date_from = record.date_range_id.date_start
|
||||||
|
record.date_to = record.date_range_id.date_end
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def preview(self):
|
def preview(self):
|
||||||
assert len(self) == 1
|
assert len(self) == 1
|
||||||
|
|
|
@ -230,6 +230,12 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="MIS Report Instance" version="7.0">
|
<form string="MIS Report Instance" version="7.0">
|
||||||
<sheet>
|
<sheet>
|
||||||
|
<div class="oe_right oe_button_box" name="buttons">
|
||||||
|
<button type="object" name="preview" string="Preview" icon="gtk-print-preview" />
|
||||||
|
<button type="object" name="print_pdf" string="Print" icon="gtk-print" />
|
||||||
|
<button type="object" name="export_xls" string="Export" icon="gtk-go-down" />
|
||||||
|
<button type="action" name="%(mis_report_instance_add_to_dashboard_action)d" string="Add to dashboard" icon="gtk-add" />
|
||||||
|
</div>
|
||||||
<div class="oe_title">
|
<div class="oe_title">
|
||||||
<div class="oe_edit_only">
|
<div class="oe_edit_only">
|
||||||
<label for="name"/>
|
<label for="name"/>
|
||||||
|
@ -237,47 +243,46 @@
|
||||||
<h1>
|
<h1>
|
||||||
<field name="name" placeholder="Name"/>
|
<field name="name" placeholder="Name"/>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
|
||||||
<div class="oe_right oe_button_box" name="buttons">
|
|
||||||
<button type="object" name="preview" string="Preview" icon="gtk-print-preview" />
|
|
||||||
<button type="object" name="print_pdf" string="Print" icon="gtk-print" />
|
|
||||||
<button type="object" name="export_xls" string="Export" icon="gtk-go-down" />
|
|
||||||
<button type="action" name="%(mis_report_instance_add_to_dashboard_action)d" string="Add to dashboard" icon="gtk-add" />
|
|
||||||
</div>
|
|
||||||
<group col="4">
|
|
||||||
<field name="report_id" colspan="4"/>
|
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
<field name="landscape_pdf" />
|
</div>
|
||||||
<field name="company_id" groups="base.group_multi_company"/>
|
<group>
|
||||||
<field name="target_move"/>
|
<group>
|
||||||
|
<field name="report_id"/>
|
||||||
|
<field name="target_move" widget="radio"/>
|
||||||
|
<field name="landscape_pdf"/>
|
||||||
|
<field name="comparison_mode"/>
|
||||||
|
<field name="company_id" groups="base.group_multi_company"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<group name="simple_mode"
|
||||||
|
attrs="{'invisible': [('comparison_mode', '=', True)]}" colspan="4">
|
||||||
|
<field name="date_range_id"/>
|
||||||
|
<field name="date_from" attrs="{'required': [('comparison_mode', '=', False)]}"/>
|
||||||
|
<field name="date_to" attrs="{'required': [('comparison_mode', '=', False)]}"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group col="4" string="Periods">
|
<group name="comparison_mode" string="Comparison"
|
||||||
<group colspan="2">
|
attrs="{'invisible': [('comparison_mode', '=', False)]}" colspan="4">
|
||||||
<field name="date"/>
|
<field name="period_ids" colspan="4" nolabel="1" attrs="{'required': [('comparison_mode', '=', True)]}">
|
||||||
</group>
|
<tree string="KPI's" colors="red:valid==False">
|
||||||
<newline/>
|
<field name="sequence" widget="handle"/>
|
||||||
<group colspan="4">
|
<field name="name"/>
|
||||||
<field name="period_ids" colspan="4" nolabel="1">
|
<field name="type"/>
|
||||||
<tree string="KPI's" editable="bottom" colors="red:valid==False">
|
<field name="date_range_type_id"
|
||||||
<field name="sequence" widget="handle"/>
|
attrs="{'invisible': [('type', '!=', 'date_range')], 'required': [('type', '=', 'date_range')]}"/>
|
||||||
<field name="name"/>
|
<field name="date_from"/>
|
||||||
<field name="type"/>
|
<field name="date_to"/>
|
||||||
<field name="date_range_type_id" attrs="{'invisible': [('type', '!=', 'date_range')], 'required': [('type', '=', 'date_range')]}"/>
|
<field name="valid" invisible="1"/>
|
||||||
<field name="offset"/>
|
<field name="report_instance_id" invisible="1"/>
|
||||||
<field name="duration"/>
|
<field name="id" invisible="1"/>
|
||||||
<field name="normalize_factor"/>
|
<field name="subkpi_ids"
|
||||||
<field name="date_from"/>
|
domain="[('report_id', '=', parent.report_id)]"
|
||||||
<field name="date_to"/>
|
widget="many2many_tags"/>
|
||||||
<field name="valid" invisible="1"/>
|
<field name="comparison_column_ids" domain="[('report_instance_id', '=', report_instance_id), ('id', '!=', id)]" widget="many2many_tags"/>
|
||||||
<field name="report_instance_id" invisible="1"/>
|
</tree>
|
||||||
<field name="id" invisible="1"/>
|
</field>
|
||||||
<field name="subkpi_ids"
|
<field name="date"/>
|
||||||
domain="[('report_id', '=', parent.report_id)]"
|
|
||||||
widget="many2many_tags"/>
|
|
||||||
<field name="comparison_column_ids" domain="[('report_instance_id', '=', report_instance_id), ('id', '!=', id)]" widget="many2many_tags"/>
|
|
||||||
</tree>
|
|
||||||
</field>
|
|
||||||
</group>
|
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
|
@ -294,5 +299,56 @@
|
||||||
|
|
||||||
<menuitem id="mis_report_instance_view_menu" parent="account.menu_finance_reports" name="MIS Reports" action="mis_report_instance_view_action" sequence="101"/>
|
<menuitem id="mis_report_instance_view_menu" parent="account.menu_finance_reports" name="MIS Reports" action="mis_report_instance_view_action" sequence="101"/>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="mis_report_instance_period_view_form">
|
||||||
|
<field name="model">mis.report.instance.period</field>
|
||||||
|
<field name="priority" eval="16"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="KPI's">
|
||||||
|
<sheet>
|
||||||
|
<div class="oe_title">
|
||||||
|
<div class="oe_edit_only">
|
||||||
|
<label for="name"/>
|
||||||
|
</div>
|
||||||
|
<h1>
|
||||||
|
<field name="name" placeholder="Name"/>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<group>
|
||||||
|
<field name="mode" widget="radio"/>
|
||||||
|
<group name="relative" attrs="{'invisible': [('mode', '!=', 'relative')]}" colspan="4">
|
||||||
|
<group>
|
||||||
|
<field name="type"/>
|
||||||
|
<field name="date_range_type_id"
|
||||||
|
attrs="{'invisible': [('type', '!=', 'date_range')], 'required': [('type', '=', 'date_range')]}"/>
|
||||||
|
<field name="offset"/>
|
||||||
|
<field name="duration"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="date_from"/>
|
||||||
|
<field name="date_to"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<group name="fix" attrs="{'invisible': [('mode', '!=', 'fix')]}" colspan="4">
|
||||||
|
<field name="date_range_id"/>
|
||||||
|
<field name="manual_date_from"
|
||||||
|
attrs="{'required': [('mode', '=', 'fix')]}"/>
|
||||||
|
<field name="manual_date_to"
|
||||||
|
attrs="{'required': [('mode', '=', 'fix')]}"/>
|
||||||
|
</group>
|
||||||
|
<field name="normalize_factor"/>
|
||||||
|
<field name="report_instance_id" invisible="1"/>
|
||||||
|
<field name="id" invisible="1"/>
|
||||||
|
<field name="subkpi_ids"
|
||||||
|
domain="[('report_id', '=', parent.report_id)]"
|
||||||
|
widget="many2many_tags"/>
|
||||||
|
<field name="comparison_column_ids"
|
||||||
|
domain="[('report_instance_id', '=', report_instance_id), ('id', '!=', id)]"
|
||||||
|
widget="many2many_tags"/>
|
||||||
|
</group>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
Loading…
Reference in New Issue