Browse Source

[ENH] Transformed mass.object's model_list char field into a proper m2m field.

pull/2/head
Virgil Dupras 12 years ago
parent
commit
4442424891
  1. 12
      mass_editing/mass_editing.py
  2. 4
      mass_editing/mass_editing_view.xml

12
mass_editing/mass_editing.py

@ -50,7 +50,7 @@ class mass_object(orm.Model):
of the related document model"), of the related document model"),
'ref_ir_value':fields.many2one('ir.values', 'Sidebar Button', readonly=True, 'ref_ir_value':fields.many2one('ir.values', 'Sidebar Button', readonly=True,
help="Sidebar button to open the sidebar action"), help="Sidebar button to open the sidebar action"),
'model_list': fields.char('Model List', size=256)
'model_ids': fields.many2many('ir.model', string='Model List')
} }
_sql_constraints = [ _sql_constraints = [
@ -60,15 +60,15 @@ class mass_object(orm.Model):
def onchange_model(self, cr, uid, ids, model_id, context=None): def onchange_model(self, cr, uid, ids, model_id, context=None):
if context is None: context = {} if context is None: context = {}
if not model_id: if not model_id:
return {'value': {'model_list': ''}}
model_list = [model_id]
return {'value': {'model_ids': [(6, 0, [])]}}
model_ids = [model_id]
model_obj = self.pool.get('ir.model') model_obj = self.pool.get('ir.model')
active_model_obj = self.pool.get(model_obj.browse(cr, uid, model_id).model) active_model_obj = self.pool.get(model_obj.browse(cr, uid, model_id).model)
if active_model_obj._inherits: if active_model_obj._inherits:
for key, val in active_model_obj._inherits.items(): for key, val in active_model_obj._inherits.items():
model_ids = model_obj.search(cr, uid, [('model', '=', key)], context=context)
model_list += model_ids
return {'value': {'model_list': str(model_list)}}
found_model_ids = model_obj.search(cr, uid, [('model', '=', key)], context=context)
model_ids += found_model_ids
return {'value': {'model_ids': [(6, 0, model_ids)]}}
def create_action(self, cr, uid, ids, context=None): def create_action(self, cr, uid, ids, context=None):
vals = {} vals = {}

4
mass_editing/mass_editing_view.xml

@ -10,11 +10,11 @@
<form string="Object"> <form string="Object">
<field name="name"/> <field name="name"/>
<field name="model_id" on_change="onchange_model(model_id)"/> <field name="model_id" on_change="onchange_model(model_id)"/>
<field name="model_list" invisible="1"/>
<field name="model_ids" invisible="1"/>
<notebook colspan="4"> <notebook colspan="4">
<page string="Fields"> <page string="Fields">
<field name="field_ids" colspan="4" nolabel="1" <field name="field_ids" colspan="4" nolabel="1"
domain="[('ttype', 'not in', ['one2many', 'reference', 'function']), ('model_id', 'in', model_list)]"/>
domain="[('ttype', 'not in', ['one2many', 'reference', 'function']), ('model_id', 'in', model_ids[0][2])]"/>
</page> </page>
<page string="Advanced"> <page string="Advanced">
<group colspan="2" col="2"> <group colspan="2" col="2">

Loading…
Cancel
Save