[MERGE]: Merge work of aag for new wizards to be appeared in config panel (Work in progress)

bzr revid: rpa@tinyerp.com-20110411102051-eqb1t4j3bdbs7njx
This commit is contained in:
Rucha (Open ERP) 2011-04-11 15:50:51 +05:30
commit 6e8ea475f5
4 changed files with 191 additions and 5 deletions

View File

@ -180,6 +180,40 @@
</search>
</field>
</record>
<!--
======================
Logo wiz
======================
-->
<record id="view_res_company_logo" model="ir.ui.view">
<field name="name">res.company.logo.form</field>
<field name="model">res.company.logo</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Upload Logo">
<separator string="Upload your company logo in JPG or PNG with a format similar to 450*150 pixels" colspan="4"/>
<field colspan="4" height="150" name="logo" widget="image" nolabel="1"/>
<separator colspan="4"/>
<group colspan="4" col="6">
<label string="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-ok" string="Upload" name="execute" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_res_company_logo" model="ir.actions.act_window">
<field name="name">Set Logo</field>
<field name="res_model">res.company.logo</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_res_company_logo"/>
<field name="target">new</field>
</record>
<!--
======================
Company
@ -198,12 +232,16 @@
</group>
<notebook colspan="4">
<page string="General Information">
<group colspan="4">
<field name="rml_header1" colspan="4"/>
<field name="rml_footer1" colspan="4"/>
<field name="rml_footer2" colspan="4"/>
<field name="currency_id"/>
<separator colspan="4" string="Your Logo - Use a size of about 450x150 pixels."/>
<field colspan="4" name="logo" widget="image"/>
<field name="currency_id" colspan="2"/>
</group>
<separator string="" colspan="4"/>
<button name="createReport" string="Preview Reports" type="object" icon="gtk-print"/>
<button name="%(action_res_company_logo)d"
string="Upload/Change Logo" type="action" icon="gtk-open"/>
</page>
<page string="Header/Footer" groups="base.group_extended">
<field colspan="4" name="rml_header" nolabel="1"/>
@ -304,6 +342,27 @@
<field name="view_id" ref="view_users_configuration_form"/>
<field name="target">new</field>
</record>
<!-- Config Wiz Give access to others users-->
<record id="action_config_access_other_user" model="ir.actions.act_window">
<field name="name">Give access to others users</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.users</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_users_form"/>
</record>
<!-- register configuration wizard -->
<record id="config_wizard_action_config_user_form" model="ir.actions.todo">
<field name="action_id" ref="action_config_access_other_user"/>
<field name="restart">never</field>
<field name="target">current</field>
<field name="sequence">1000</field>
<field name="state">skip</field>
</record>
<record id="view_confirm_simple_view_form" model="ir.ui.view">
<field name="name">Configure Your Interface</field>
@ -358,5 +417,58 @@
<field name="sequence">1</field>
<field name="state">skip</field>
</record>
<!-- Define default users preferences-->
<record id="view_user_preferences_config_form" model="ir.ui.view">
<field name="name">Define default users preferences</field>
<field name="model">user.preferences.config</field>
<field name="type">form</field>
<field name="inherit_id" ref="res_config_view_base"/>
<field name="arch" type="xml">
<data>
<form position="attributes">
<attribute name="string">Define default users preferences</attribute>
</form>
<xpath expr='//separator[@string="title"]' position='attributes'>
<attribute name='string'>Define default users preferences</attribute>
</xpath>
<xpath expr="//label[@string='description']"
position="attributes">
<attribute name="string">Specify default values. These data are just default values, each user is free to change his own preferences.</attribute>
</xpath>
<xpath expr='//separator[@string="vsep"]' position='attributes'>
<attribute name='string'></attribute>
<attribute name='rowspan'>12</attribute>
</xpath>
<group string="res_config_contents" position="replace">
<group colspan="4">
<field colspan="4" name="context_tz" />
<field colspan="4" name="context_lang" />
<field colspan="4" name="view" />
<field colspan="4" name="menu_tips" />
</group>
</group>
</data>
</field>
</record>
<record id="action_user_preferences_config_form" model="ir.actions.act_window">
<field name="name">Define default users preferences</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">user.preferences.config</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_user_preferences_config_form"/>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<!-- Register configuration wizard -->
<record id="config_action_user_preferences_config_form" model="ir.actions.todo">
<field name="action_id" ref="action_user_preferences_config_form"/>
<field name="restart">on_trigger</field>
</record>
</data>
</openerp>

View File

@ -832,8 +832,8 @@ class ir_actions_todo(osv.osv):
context = {}
wizard_id = ids and ids[0] or False
wizard = self.browse(cr, uid, wizard_id, context=context)
res = self.pool.get('ir.actions.act_window').read(cr, uid, wizard.action_id.id, ['name', 'view_type', 'view_mode', 'res_model', 'context', 'views', 'type'], context=context)
res.update({'target':'new', 'nodestroy': True})
res = self.pool.get('ir.actions.act_window').read(cr, uid, wizard.action_id.id, ['name', 'view_type', 'view_mode', 'res_model', 'context', 'views', 'type','target'], context=context)
res.update({'nodestroy': True})
return res
def action_open(self, cr, uid, ids, context=None):

View File

@ -68,6 +68,25 @@ class multi_company_default(osv.osv):
multi_company_default()
class res_company_logo(osv.osv_memory):
_name = 'res.company.logo'
_columns = {
'logo' : fields.binary('Logo'),
}
_defaults={
'logo':lambda self,cr,uid,c: self.pool.get('res.company').browse(cr, uid, uid,c).logo,
}
def execute(self, cr, uid, ids, context=None):
if context is None:
context = {}
record_id = context.get('active_id', False) or False
comp_obj = self.pool.get("res.company")
get_val = self.browse(cr, uid, ids)[0]
comp_obj.write(cr, uid, record_id, {'logo': get_val.logo}, context=context)
return {'type': 'ir.actions.act_window_close'}
res_company_logo()
class res_company(osv.osv):
_name = "res.company"
@ -138,6 +157,26 @@ class res_company(osv.osv):
return []
ids = self.search(cr, uid, [('parent_id','child_of',[company])])
return ids
# For Report
def createReport(cr, uid, report, ids, name=False):
files = []
for id in ids:
try:
service = netsvc.LocalService(report)
(result, format) = service.create(cr, uid, [id], {}, {})
if not name:
report_file = '/tmp/reports'+ str(id) + '.pdf'
else:
report_file = name
fp = open(report_file,'wb+')
fp.write(result);
fp.close();
files += [report_file]
except Exception,e:
continue
return files
def _get_partner_hierarchy(self, cr, uid, company_id, context={}):
if company_id:

View File

@ -604,4 +604,39 @@ class res_config_view(osv.osv_memory):
res_config_view()
# Define default users preferences config wiz
class user_preferences_config(osv.osv_memory):
_name = 'user.preferences.config'
_inherit = 'res.config'
_columns = {
'context_tz': fields.selection(_tz_get, 'Timezone', size=64,
help="Set default for new user's timezone, used to perform timezone conversions "
"between the server and the client."),
'context_lang': fields.selection(_lang_get, 'Language', required=True,
help="Sets default language for the new user's user interface, when UI "
"translations are available"),
'view': fields.selection([('simple','Simplified'),
('extended','Extended')],
'Interface', required=True ),
'menu_tips': fields.boolean('Menu Tips', help="Check out this box if you want to always display tips on each menu action"),
}
_defaults={
'view' : lambda self,cr,uid,*args: self.pool.get('res.users').browse(cr, uid, uid).view or 'simple',
'context_lang' : 'en_US',
'menu_tips' : True
}
def execute(self, cr, uid, ids, context=None):
for o in self.browse(cr, uid, ids, context=context):
ir_values_obj = self.pool.get('ir.values')
ir_values_obj.set(cr, uid, 'default', False, 'context_tz', ['res.users'], o.context_tz)
ir_values_obj.set(cr, uid, 'default', False, 'context_lang', ['res.users'], o.context_lang)
ir_values_obj.set(cr, uid, 'default', False, 'view', ['res.users'], o.view)
ir_values_obj.set(cr, uid, 'default', False, 'menu_tips', ['res.users'], o.menu_tips)
return {}
user_preferences_config()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: