Browse Source

[IMP] add possibility to use a report as a wizard

pull/189/head
Sébastien BEAU 9 years ago
committed by Stéphane Bidoul
parent
commit
0fc529a2b8
  1. 31
      mis_builder/models/mis_builder.py
  2. 49
      mis_builder/views/mis_builder.xml

31
mis_builder/models/mis_builder.py

@ -498,6 +498,23 @@ class MisReport(models.Model):
'report_id', 'report_id',
string="Sub KPI") string="Sub KPI")
@api.multi
def get_wizard_report_action(self):
action = self.env.ref('mis_builder.mis_report_instance_view_action')
res = action.read()[0]
view = self.env.ref('mis_builder.wizard_mis_report_instance_view_form')
res.update({
'view_id': view.id,
'views': [(view.id, 'form')],
'target':'new',
'context': {
'default_report_id': self.id,
'default_name': self.name,
'default_temporary': True,
}
})
return res
@api.one @api.one
def copy(self, default=None): def copy(self, default=None):
default = dict(default or {}) default = dict(default or {})
@ -1041,6 +1058,20 @@ class MisReportInstance(models.Model):
string='Date Range') string='Date Range')
date_from = fields.Date(string="From") date_from = fields.Date(string="From")
date_to = fields.Date(string="To") date_to = fields.Date(string="To")
temporary = fields.Boolean()
@api.multi
def save_report(self):
self.ensure_one()
self.write({'temporary': False})
action = self.env.ref('mis_builder.mis_report_instance_view_action')
res = action.read()[0]
view = self.env.ref('mis_builder.mis_report_instance_view_form')
res.update({
'views': [(view.id, 'form')],
'res_id': self.id,
})
return res
@api.one @api.one
def copy(self, default=None): def copy(self, default=None):

49
mis_builder/views/mis_builder.xml

@ -233,11 +233,13 @@
<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>
<field name="temporary" invisible="1"/>
<div class="oe_right oe_button_box" name="buttons"> <div class="oe_right oe_button_box" name="buttons">
<button type="object" name="preview" string="Preview" icon="gtk-print-preview" /> <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="print_pdf" string="Print" icon="gtk-print" />
<button type="object" name="export_xls" string="Export" icon="gtk-go-down" /> <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" />
<button type="action" name="%(mis_report_instance_add_to_dashboard_action)d" string="Add to dashboard" icon="gtk-add" attrs="{'invisible': [('temporary', '=', True)]}"/>
<button type="object" name="save_report" string="Save" icon="gtk-floppy" attrs="{'invisible': [('temporary', '=', False)]}"/>
</div> </div>
<div class="oe_title"> <div class="oe_title">
<div class="oe_edit_only"> <div class="oe_edit_only">
@ -302,6 +304,51 @@
<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 id="wizard_mis_report_instance_view_form" model="ir.ui.view">
<field name="model">mis.report.instance</field>
<field name="inherit_id" ref="mis_builder.mis_report_instance_view_form"/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<field name="name" position="attributes">
<attribute name="readonly">1</attribute>
</field>
<label for="name" position="replace"/>
<field name="description" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name="report_id" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<div name="buttons" position="attributes">
<attribute name="invisible">1</attribute>
</div>
<sheet position="after">
<footer>
<button type="object" name="save_report" string="Save" icon="gtk-floppy"/>
<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" />
or <button string="Cancel" class="oe_link" special="cancel" />
</footer>
</sheet>
</field>
</record>
<record model="ir.actions.act_window" id="mis_report_instance_view_action">
<field name="name">Last Reports Generated</field>
<field name="view_id" ref="mis_report_instance_view_tree"/>
<field name="res_model">mis.report.instance</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('temporary', '=', True)]</field>
</record>
<menuitem id="last_wizard_mis_report_instance_view_menu"
parent="account.menu_finance_reports"
name="Last Reports Generated"
action="mis_report_instance_view_action"
sequence="102"/>
<record model="ir.ui.view" id="mis_report_instance_period_view_form"> <record model="ir.ui.view" id="mis_report_instance_period_view_form">
<field name="model">mis.report.instance.period</field> <field name="model">mis.report.instance.period</field>
<field name="priority" eval="16"/> <field name="priority" eval="16"/>

Loading…
Cancel
Save