It is currently Sat Feb 11, 2012 10:43 am

All times are UTC + 2 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: [SOLVED] Dynamic view and fields with Wizard
PostPosted: Wed Jan 13, 2010 4:03 pm 
Offline

Joined: Thu May 31, 2007 2:56 pm
Posts: 50
Hi,
Is it anyway to assign a wizard view and fields in a dynamic way ?

Example:
Code:
states = {'init': {
'actions': [_get_defaults],
'result': {'type': 'form', 'arch': form, 'fields': fields, 'state':[('end','Cancel'), ('send','Send')]}
},}


The _get_defaults() changes "form" and "fields" content.

Thanks in advance for any solution.

Regards,
Nicolas DS


Last edited by zyphos on Wed Jan 13, 2010 4:25 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 13, 2010 4:24 pm 
Offline

Joined: Thu May 31, 2007 2:56 pm
Posts: 50
After seeking in OpenObject server source:

Here is the way to achieve this:
Code:
def _get_defaults(self, cr, user, data, context):
    self.states['init']['result']['arch'] =  '''<?xml version="1.0"?><!-- My new view -->'''
    self.states['init']['result']['fields']['my_new_field'] = {'string':'My field', 'type':'boolean'}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 01, 2010 6:08 pm 
Offline

Joined: Thu May 31, 2007 2:56 pm
Posts: 50
Another way to achieve this with osv.osv and osv.osv_memory is to do like in base_module/ir/ir_model.py @ class ir_model_grid(osv.osv):

Code:
def fields_get(self, cr, uid, fields=None, context=None, read_access=True):
        result = super(ir_model_grid, self).fields_get(cr, uid, fields, context)
        groups = self.pool.get('res.groups').search(cr, uid, [])
        groups_br = self.pool.get('res.groups').browse(cr, uid, groups)
        result['group_0'] = {'string': 'All Users','type': 'char','size': 7}
        for group in groups_br:
            result['group_%d'%group.id] = {'string': '%s'%group.name,'type': 'char','size': 7}
        return result

    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False):
        result = super(ir_model_grid, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar)
        groups = self.pool.get('res.groups').search(cr, uid, [])
        groups_br = self.pool.get('res.groups').browse(cr, uid, groups)
        cols = ['model', 'name']
        xml = '''<?xml version="1.0"?>
<%s editable="bottom">
    <field name="name" select="1" readonly="1" required="1"/>
    <field name="model" select="1" readonly="1" required="1"/>
    <field name="group_0"/>
    ''' % (view_type,)
        for group in groups_br:
            xml += '''<field name="group_%d"/>''' % (group.id, )
        xml += '''</%s>''' % (view_type,)
        result['arch'] = xml
        result['fields'] = self.fields_get(cr, uid, cols, context)
        return result

Thank you to Albert Cervera i Areny for the tip.


Top
 Profile  
 
 Post subject: Re: [SOLVED] Dynamic view and fields with Wizard
PostPosted: Fri Oct 08, 2010 3:38 am 
Offline

Joined: Thu Jul 29, 2010 4:50 pm
Posts: 85
Hello,

Is there a way or place I can find the "technical" names for the user groups?

So far I have found 2:

a) account.group_account_manager
b) base.group_extended

Which I think refer to:

a) Finance /Manager
b) Useability / Extended View

But I still need the rest of the groups.

I really appreciate your time and comments.

Regards,
V

_________________
Shall do my best


Top
 Profile  
 
 Post subject: Re: [SOLVED] Dynamic view and fields with Wizard
PostPosted: Wed Jul 06, 2011 5:37 pm 
Offline

Joined: Tue Jan 18, 2011 5:16 pm
Posts: 235
Hi,

can your finding help me achieve this:
Is it possible to dynamically filter the views of a dashboard based on the other view of the dashboard?
EG.

I make a dashboard with Manufacturing orders and work orders.

I want to look at one manufacturing order in one view and the corresponding work orders in other view.

Or something similar?

Thank you.
Mihai

_________________
OpenERP debugging with Eclipse on headless server


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP