[REM]:base:removed ir.actions.report.custom and ir.report.custom
bzr revid: jas@tinyerp.com-20101001135358-ndjdcdw9hojno9kh
This commit is contained in:
parent
dc984c48b6
commit
48d9c128e0
|
@ -389,59 +389,6 @@
|
|||
<menuitem parent="base.next_id_6" name="Filters"
|
||||
id="menu_ir_filters" action="actions_ir_filters_view" />
|
||||
|
||||
|
||||
<record id="act_report_custom_view" model="ir.ui.view">
|
||||
<field name="name">ir.actions.report.custom</field>
|
||||
<field name="model">ir.actions.report.custom</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Report custom">
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
<field name="report_id"/>
|
||||
<field name="usage"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="act_report_custom_view_tree" model="ir.ui.view">
|
||||
<field name="name">ir.actions.report.custom.tree</field>
|
||||
<field name="model">ir.actions.report.custom</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Report custom">
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="act_report_custom_search_view" model="ir.ui.view">
|
||||
<field name="name">ir.actions.report.custom.search</field>
|
||||
<field name="model">ir.actions.report.custom</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Report custom">
|
||||
<group colspan="4" col="10">
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By" colspan="4">
|
||||
<filter string="Type" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'type'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="ir_action_report_custom" model="ir.actions.act_window">
|
||||
<field name="name">Report Custom</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">ir.actions.report.custom</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="act_report_custom_view_tree"/>
|
||||
<field name="search_view_id" ref="act_report_custom_search_view"/>
|
||||
</record>
|
||||
<menuitem action="ir_action_report_custom" id="menu_ir_action_report_custom" parent="base.next_id_6"/>
|
||||
|
||||
<record id="act_report_xml_view" model="ir.ui.view">
|
||||
<field name="name">ir.actions.report.xml</field>
|
||||
<field name="model">ir.actions.report.xml</field>
|
||||
|
@ -1067,42 +1014,6 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_report_custom_form" model="ir.ui.view">
|
||||
<field name="name">ir.report.custom</field>
|
||||
<field name="model">ir.report.custom</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Custom Report">
|
||||
<field name="name" select="1"/>
|
||||
<field name="model_id" on_change="onchange_model_id(model_id)" select="1"/>
|
||||
<field name="title"/>
|
||||
<field name="type"/>
|
||||
<field name="print_format"/>
|
||||
<field name="print_orientation"/>
|
||||
<field name="repeat_header"/>
|
||||
<field name="footer"/>
|
||||
<field name="sortby"/>
|
||||
<field name="field_parent"/>
|
||||
<field name="frequency"/>
|
||||
<field name="limitt"/>
|
||||
<field name="menu_id"/>
|
||||
<field colspan="4" name="fields_child0" widget="one2many_list"/>
|
||||
<field name="state" readonly="1" select="1"/>
|
||||
<group col="2" colspan="2">
|
||||
<button name="subscribe" states="unsubscribed" string="Subscribe Report" type="object"/>
|
||||
<button name="unsubscribe" states="subscribed" string="Unsubscribe Report" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_report_custom" model="ir.actions.act_window">
|
||||
<field name="name">Custom Report</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">ir.report.custom</field>
|
||||
<field name="view_type">tree</field>
|
||||
<field name="view_id" ref="view_report_custom_form"/>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
<menuitem name="Administration/Report/Report Custom" action="action_report_custom"/>
|
||||
-->
|
||||
|
|
|
@ -44,23 +44,6 @@ class actions(osv.osv):
|
|||
}
|
||||
actions()
|
||||
|
||||
class report_custom(osv.osv):
|
||||
_name = 'ir.actions.report.custom'
|
||||
_table = 'ir_act_report_custom'
|
||||
_sequence = 'ir_actions_id_seq'
|
||||
_columns = {
|
||||
'name': fields.char('Report Name', size=64, required=True, translate=True),
|
||||
'type': fields.char('Report Type', size=32, required=True),
|
||||
'model':fields.char('Object', size=64, required=True),
|
||||
'report_id': fields.integer('Report Ref.', required=True),
|
||||
'usage': fields.char('Action Usage', size=32),
|
||||
'multi': fields.boolean('On multiple doc.', help="If set to true, the action will not be displayed on the right toolbar of a form view.")
|
||||
}
|
||||
_defaults = {
|
||||
'multi': lambda *a: False,
|
||||
'type': lambda *a: 'ir.actions.report.custom',
|
||||
}
|
||||
report_custom()
|
||||
|
||||
class report_xml(osv.osv):
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -27,127 +27,24 @@ from tools.translate import _
|
|||
from tools.safe_eval import safe_eval as eval
|
||||
import netsvc
|
||||
|
||||
class report_custom(osv.osv):
|
||||
_name = 'ir.report.custom'
|
||||
_columns = {
|
||||
'name': fields.char('Report Name', size=64, required=True, translate=True),
|
||||
'model_id': fields.many2one('ir.model','Object', required=True, change_default=True),
|
||||
'type': fields.selection([('table','Tabular'),('pie','Pie Chart'),('bar','Bar Chart'),('line','Line Plot')], "Report Type", size=64, required='True'),
|
||||
'title': fields.char("Report Title", size=64, required='True', translate=True),
|
||||
'print_format': fields.selection((('A4','a4'),('A5','a5')), 'Print format', required=True),
|
||||
'print_orientation': fields.selection((('landscape','Landscape'),('portrait','Portrait')), 'Print orientation', required=True, size=16),
|
||||
'repeat_header': fields.boolean('Repeat Header'),
|
||||
'footer': fields.char('Report Footer', size=64, required=True),
|
||||
'sortby': fields.char('Sorted By', size=64),
|
||||
'fields_child0': fields.one2many('ir.report.custom.fields', 'report_id','Fields', required=True),
|
||||
'field_parent': fields.many2one('ir.model.fields','Child Field'),
|
||||
'state': fields.selection([('unsubscribed','Unsubscribed'),('subscribed','Subscribed')], 'State', size=64),
|
||||
'frequency': fields.selection([('Y','Yearly'),('M','Monthly'),('D','Daily')], 'Frequency', size=64),
|
||||
'limitt': fields.char('Limit', size=9),
|
||||
'menu_id': fields.many2one('ir.ui.menu', 'Menu')
|
||||
}
|
||||
_defaults = {
|
||||
'print_format': lambda *a: 'A4',
|
||||
'print_orientation': lambda *a: 'portrait',
|
||||
'state': lambda *a: 'unsubscribed',
|
||||
'type': lambda *a: 'table',
|
||||
'footer': lambda *a: 'Generated by OpenERP'
|
||||
}
|
||||
|
||||
def onchange_model_id(self, cr, uid, ids, model_id):
|
||||
if not(model_id):
|
||||
return {}
|
||||
return {'domain': {'field_parent': [('model_id','=',model_id)]}}
|
||||
|
||||
def unsubscribe(self, cr, uid, ids, context={}):
|
||||
#TODO: should delete the ir.actions.report.custom for these reports and do an ir_del
|
||||
self.write(cr, uid, ids, {'state':'unsubscribed'})
|
||||
return True
|
||||
|
||||
def subscribe(self, cr, uid, ids, context={}):
|
||||
for report in self.browse(cr, uid, ids):
|
||||
report.fields_child0.sort(lambda x,y : x.sequence - y.sequence)
|
||||
|
||||
# required on field0 does not seem to work( cause we use o2m_l ?)
|
||||
if not report.fields_child0:
|
||||
raise osv.except_osv(_('Invalid operation'), _('Enter at least one field !'))
|
||||
|
||||
if report.type in ['pie', 'bar', 'line'] and report.field_parent:
|
||||
raise osv.except_osv(_('Invalid operation'), _('Tree can only be used in tabular reports'))
|
||||
|
||||
# Otherwise it won't build a good tree. See level.pop in custom.py.
|
||||
if report.type == 'table' and report.field_parent and report.fields_child0 and not report.fields_child0[0].groupby:
|
||||
raise osv.except_osv('Invalid operation :', 'When creating tree (field child) report, data must be group by the first field')
|
||||
|
||||
if report.type == 'pie':
|
||||
if len(report.fields_child0) != 2:
|
||||
raise osv.except_osv(_('Invalid operation'), _('Pie charts need exactly two fields'))
|
||||
else:
|
||||
c_f = {}
|
||||
for i in range(2):
|
||||
c_f[i] = []
|
||||
tmp = report.fields_child0[i]
|
||||
for j in range(3):
|
||||
c_f[i].append((not isinstance(eval('tmp.field_child'+str(j),{},{'tmp':tmp}), browse_null) and eval('tmp.field_child'+str(j)+'.ttype',{},{'tmp':tmp})) or None)
|
||||
if not reduce(lambda x,y : x or y, map(lambda x: x in ['integer', 'float'], c_f[1])):
|
||||
raise osv.except_osv(_('Invalid operation'), _('Second field should be figures'))
|
||||
|
||||
if report.type == 'bar':
|
||||
if len(report.fields_child0) < 2:
|
||||
raise osv.except_osv(_('Invalid operation'), _('Bar charts need at least two fields'))
|
||||
else:
|
||||
c_f = {}
|
||||
for i in range(len(report.fields_child0)):
|
||||
c_f[i] = []
|
||||
tmp = report.fields_child0[i]
|
||||
for j in range(3):
|
||||
c_f[i].append((not isinstance(eval('tmp.field_child'+str(j),{},{'tmp':tmp}), browse_null) and eval('tmp.field_child'+str(j)+'.ttype',{},{'tmp':tmp})) or None)
|
||||
|
||||
if i == 0:
|
||||
pass
|
||||
else:
|
||||
if not reduce(lambda x,y : x or y, map(lambda x: x in ['integer', 'float'], c_f[i])):
|
||||
raise osv.except_osv(_('Invalid operation'), _('Field %d should be a figure') %(i,))
|
||||
|
||||
if report.state=='subscribed':
|
||||
continue
|
||||
|
||||
name = report.name
|
||||
model = report.model_id.model
|
||||
|
||||
action_def = {'report_id':report.id, 'type':'ir.actions.report.custom', 'model':model, 'name':name}
|
||||
id = self.pool.get('ir.actions.report.custom').create(cr, uid, action_def)
|
||||
m_id = report.menu_id.id
|
||||
action = "ir.actions.report.custom,%d" % (id,)
|
||||
if not report.menu_id:
|
||||
ir.ir_set(cr, uid, 'action', 'client_print_multi', name, [(model, False)], action, False, True)
|
||||
else:
|
||||
ir.ir_set(cr, uid, 'action', 'tree_but_open', 'Menuitem', [('ir.ui.menu', int(m_id))], action, False, True)
|
||||
|
||||
self.write(cr, uid, [report.id], {'state':'subscribed'}, context)
|
||||
return True
|
||||
report_custom()
|
||||
|
||||
|
||||
class report_custom_fields(osv.osv):
|
||||
_name = 'ir.report.custom.fields'
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True),
|
||||
'report_id': fields.many2one('ir.report.custom', 'Report Ref', select=True),
|
||||
'field_child0': fields.many2one('ir.model.fields', 'Field child0', required=True),
|
||||
'fc0_operande': fields.many2one('ir.model.fields', 'Constraint'),
|
||||
'fc0_operande': fields.many2one('ir.model.fields', 'Constraint'),
|
||||
'fc0_condition': fields.char('Condition', size=64),
|
||||
'fc0_op': fields.selection((('>','>'),('<','<'),('==','='),('in','in'),('gety,==','(year)=')), 'Relation'),
|
||||
'field_child1': fields.many2one('ir.model.fields', 'Field child1'),
|
||||
'fc1_operande': fields.many2one('ir.model.fields', 'Constraint'),
|
||||
'fc1_operande': fields.many2one('ir.model.fields', 'Constraint'),
|
||||
'fc1_condition': fields.char('condition', size=64),
|
||||
'fc1_op': fields.selection((('>','>'),('<','<'),('==','='),('in','in'),('gety,==','(year)=')), 'Relation'),
|
||||
'field_child2': fields.many2one('ir.model.fields', 'Field child2'),
|
||||
'fc2_operande': fields.many2one('ir.model.fields', 'Constraint'),
|
||||
'fc2_operande': fields.many2one('ir.model.fields', 'Constraint'),
|
||||
'fc2_condition': fields.char('condition', size=64),
|
||||
'fc2_op': fields.selection((('>','>'),('<','<'),('==','='),('in','in'),('gety,==','(year)=')), 'Relation'),
|
||||
'field_child3': fields.many2one('ir.model.fields', 'Field child3'),
|
||||
'fc3_operande': fields.many2one('ir.model.fields', 'Constraint'),
|
||||
'fc3_operande': fields.many2one('ir.model.fields', 'Constraint'),
|
||||
'fc3_condition': fields.char('condition', size=64),
|
||||
'fc3_op': fields.selection((('>','>'),('<','<'),('==','='),('in','in'),('gety,==','(year)=')), 'Relation'),
|
||||
'alignment': fields.selection((('left','left'),('right','right'),('center','center')), 'Alignment', required=True),
|
||||
|
@ -180,9 +77,9 @@ class report_custom_fields(osv.osv):
|
|||
if id:
|
||||
return {
|
||||
'domain': {
|
||||
next_level_field_name: [('model_id', '=', id)],
|
||||
next_level_field_name: [('model_id', '=', id)],
|
||||
next_level_operande: [('model_id', '=', id)]
|
||||
},
|
||||
},
|
||||
'required': {
|
||||
next_level_field_name: True
|
||||
}
|
||||
|
@ -192,13 +89,13 @@ class report_custom_fields(osv.osv):
|
|||
return {'required': {next_level_field_name: True}}
|
||||
else:
|
||||
return {'domain': {next_level_field_name: []}}
|
||||
|
||||
|
||||
def get_field_child_onchange_method(level):
|
||||
return lambda self, cr, uid, ids, field_id: self.onchange_any_field_child(cr, uid, ids, field_id, level)
|
||||
|
||||
onchange_field_child0 = get_field_child_onchange_method(0)
|
||||
onchange_field_child1 = get_field_child_onchange_method(1)
|
||||
onchange_field_child2 = get_field_child_onchange_method(2)
|
||||
onchange_field_child0 = get_field_child_onchange_method(0)
|
||||
onchange_field_child1 = get_field_child_onchange_method(1)
|
||||
onchange_field_child2 = get_field_child_onchange_method(2)
|
||||
report_custom_fields()
|
||||
|
||||
|
||||
|
|
|
@ -125,7 +125,6 @@ class ir_ui_menu(osv.osv):
|
|||
data = menu.action
|
||||
if data:
|
||||
model_field = { 'ir.actions.act_window': 'res_model',
|
||||
'ir.actions.report.custom': 'model',
|
||||
'ir.actions.report.xml': 'model',
|
||||
'ir.actions.wizard': 'model',
|
||||
'ir.actions.server': 'model_id',
|
||||
|
@ -272,7 +271,6 @@ class ir_ui_menu(osv.osv):
|
|||
'action': fields.function(_action, fnct_inv=_action_inv,
|
||||
method=True, type='reference', string='Action',
|
||||
selection=[
|
||||
('ir.actions.report.custom', 'ir.actions.report.custom'),
|
||||
('ir.actions.report.xml', 'ir.actions.report.xml'),
|
||||
('ir.actions.act_window', 'ir.actions.act_window'),
|
||||
('ir.actions.wizard', 'ir.actions.wizard'),
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
"access_ir_module_module_dependency_group_system","ir_module_module_dependency group_system","model_ir_module_module_dependency","group_system",1,1,1,1
|
||||
"access_ir_property_group_user","ir_property group_user","model_ir_property",,1,0,0,0
|
||||
"access_ir_property_group_user_manager","ir_property group_manager","model_ir_property","base.group_partner_manager",1,1,1,0
|
||||
"access_ir_report_custom_group_system","ir_report_custom group_system","model_ir_report_custom",,1,0,0,0
|
||||
"access_ir_report_custom_fields_group_system","ir_report_custom_fields group_system","model_ir_report_custom_fields",,1,0,0,0
|
||||
"access_ir_rule_group_user","ir_rule group_user","model_ir_rule",,1,0,0,0
|
||||
"access_ir_rule_group_erp_manager","ir_rule group_erp_manager","model_ir_rule","group_erp_manager",1,1,1,1
|
||||
|
@ -99,8 +98,6 @@
|
|||
"access_workflow_triggers_all","workflow_triggers_all","model_workflow_triggers",,1,0,0,0
|
||||
"access_workflow_triggers_group_system","workflow_triggers_group_system","model_workflow_triggers","group_system",1,1,1,1
|
||||
"access_workflow_workitem_all","workflow_workitem_all","model_workflow_workitem",,1,1,1,1
|
||||
"access_actions_report_custom_all","ir_actions_report_custom_all","model_ir_actions_report_custom",,1,0,0,0
|
||||
"access_actions_report_custom_group_system","ir_actions_report_custom_group_system","model_ir_actions_report_custom","group_system",1,1,1,1
|
||||
"access_ir_actions_act_window_view_all","ir_actions_act_window_view_all","model_ir_actions_act_window_view",,1,0,0,0
|
||||
"access_ir_actions_act_window_view_group_system","ir_actions_act_window_view_group_system","model_ir_actions_act_window_view","group_system",1,1,1,1
|
||||
"access_ir_actions_url_all","ir_actions_url_all","model_ir_actions_url",,1,0,0,0
|
||||
|
|
|
Loading…
Reference in New Issue