Browse Source

[IMP] add cron for deleting temporary report, improve view and fix period creation

pull/189/head
Sébastien BEAU 9 years ago
parent
commit
43fd454c24
  1. 1
      mis_builder/__openerp__.py
  2. 18
      mis_builder/datas/ir_cron.xml
  3. 13
      mis_builder/models/mis_builder.py
  4. 17
      mis_builder/views/mis_builder.xml

1
mis_builder/__openerp__.py

@ -20,6 +20,7 @@
'data': [
'wizard/mis_builder_dashboard.xml',
'views/mis_builder.xml',
'datas/ir_cron.xml',
'security/ir.model.access.csv',
'security/mis_builder_security.xml',
'report/report_mis_report_instance.xml',

18
mis_builder/datas/ir_cron.xml

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data noupdate="1">
<record id="ir_cron_crm_action" model="ir.cron">
<field name="name">Vaccum temporary report</field>
<field name="interval_number">4</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'mis.report.instance'" name="model"/>
<field eval="'_vacuum_report'" name="function"/>
<field eval="'(24,)'" name="args"/>
<field name="active" eval="True" />
</record>
</data>
</openerp>

13
mis_builder/models/mis_builder.py

@ -810,7 +810,6 @@ class MisReportInstancePeriod(models.Model):
('w', _('Week')),
('date_range', _('Date Range'))
],
required=True,
string='Period type')
date_range_type_id = fields.Many2one(
comodel_name='date.range.type', string='Date Range Type')
@ -864,6 +863,7 @@ class MisReportInstancePeriod(models.Model):
for record in self:
record.manual_date_from = record.date_range_id.date_start
record.manual_date_to = record.date_range_id.date_end
record.name = record.date_range_id.name
@api.multi
def _get_additional_move_line_filter(self):
@ -1089,6 +1089,17 @@ class MisReportInstance(models.Model):
})
return res
@api.model
def _vacuum_report(self, hours=24):
clear_date = fields.Datetime.to_string(
datetime.datetime.now() - datetime.timedelta(hours=hours))
reports = self.search([
('write_date', '<', clear_date),
('temporary', '=', True),
])
_logger.debug('Vacuum %s Temporary MIS Builder Report', len(reports))
return reports.unlink()
@api.one
def copy(self, default=None):
default = dict(default or {})

17
mis_builder/views/mis_builder.xml

@ -296,9 +296,6 @@
<tree string="KPI's" colors="red:valid==False">
<field name="sequence" widget="handle"/>
<field name="name"/>
<field name="type"/>
<field name="date_range_type_id"
attrs="{'invisible': [('type', '!=', 'date_range')], 'required': [('type', '=', 'date_range')]}"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="valid" invisible="1"/>
@ -323,7 +320,7 @@
<field name="res_model">mis.report.instance</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain"></field>
<field name="domain">[('temporary', '=', False)]</field>
</record>
<menuitem id="mis_report_instance_view_menu" parent="account.menu_finance_reports" name="MIS Reports" action="mis_report_instance_view_action" sequence="101"/>
@ -376,19 +373,12 @@
<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"/>
<field name="valid" invisible="1"/>
<group name="relative" attrs="{'invisible': [('mode', '!=', 'relative')]}" colspan="4">
<group>
<field name="type"/>
<field name="type" attrs="{'required': [('mode', '=', 'relative')]}"/>
<field name="date_range_type_id"
attrs="{'invisible': [('type', '!=', 'date_range')], 'required': [('type', '=', 'date_range')]}"/>
<field name="offset"/>
@ -406,6 +396,7 @@
<field name="manual_date_to"
attrs="{'required': [('mode', '=', 'fix')]}"/>
</group>
<field name="name" placeholder="Name"/>
<field name="normalize_factor"/>
<field name="report_instance_id" invisible="1"/>
<field name="id" invisible="1"/>

Loading…
Cancel
Save