Skip to content

Commit 4442424

Browse files
author
Virgil Dupras
committed
[ENH] Transformed mass.object's model_list char field into a proper m2m field.
1 parent c099945 commit 4442424

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

mass_editing/mass_editing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class mass_object(orm.Model):
5050
of the related document model"),
5151
'ref_ir_value':fields.many2one('ir.values', 'Sidebar Button', readonly=True,
5252
help="Sidebar button to open the sidebar action"),
53-
'model_list': fields.char('Model List', size=256)
53+
'model_ids': fields.many2many('ir.model', string='Model List')
5454
}
5555

5656
_sql_constraints = [
@@ -60,15 +60,15 @@ class mass_object(orm.Model):
6060
def onchange_model(self, cr, uid, ids, model_id, context=None):
6161
if context is None: context = {}
6262
if not model_id:
63-
return {'value': {'model_list': ''}}
64-
model_list = [model_id]
63+
return {'value': {'model_ids': [(6, 0, [])]}}
64+
model_ids = [model_id]
6565
model_obj = self.pool.get('ir.model')
6666
active_model_obj = self.pool.get(model_obj.browse(cr, uid, model_id).model)
6767
if active_model_obj._inherits:
6868
for key, val in active_model_obj._inherits.items():
69-
model_ids = model_obj.search(cr, uid, [('model', '=', key)], context=context)
70-
model_list += model_ids
71-
return {'value': {'model_list': str(model_list)}}
69+
found_model_ids = model_obj.search(cr, uid, [('model', '=', key)], context=context)
70+
model_ids += found_model_ids
71+
return {'value': {'model_ids': [(6, 0, model_ids)]}}
7272

7373
def create_action(self, cr, uid, ids, context=None):
7474
vals = {}

mass_editing/mass_editing_view.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
<form string="Object">
1111
<field name="name"/>
1212
<field name="model_id" on_change="onchange_model(model_id)"/>
13-
<field name="model_list" invisible="1"/>
13+
<field name="model_ids" invisible="1"/>
1414
<notebook colspan="4">
1515
<page string="Fields">
1616
<field name="field_ids" colspan="4" nolabel="1"
17-
domain="[('ttype', 'not in', ['one2many', 'reference', 'function']), ('model_id', 'in', model_list)]"/>
17+
domain="[('ttype', 'not in', ['one2many', 'reference', 'function']), ('model_id', 'in', model_ids[0][2])]"/>
1818
</page>
1919
<page string="Advanced">
2020
<group colspan="2" col="2">

0 commit comments

Comments
 (0)