Browse Source

[IMP] mass_editing: Corrections based on the merge comments

pull/29/head
Anu Patel 12 years ago
committed by Aitor Bouzas
parent
commit
ae59feaff3
  1. 46
      mass_editing/mass_editing.py
  2. 2
      mass_editing/security/ir.model.access.csv
  3. 16
      mass_editing/wizard/mass_editing_wizard.py

46
mass_editing/mass_editing.py

@ -19,12 +19,12 @@
# #
############################################################################## ##############################################################################
from osv import fields, osv
from tools.translate import _
from openerp.osv import orm, fields
import openerp.tools
from openerp.tools.translate import _
from lxml import etree from lxml import etree
from openerp import tools
class ir_model_fields(osv.osv):
class ir_model_fields(orm.Model):
_inherit = 'ir.model.fields' _inherit = 'ir.model.fields'
def search(self, cr, uid, args, offset=0, limit=0, order=None, context=None, count=False): def search(self, cr, uid, args, offset=0, limit=0, order=None, context=None, count=False):
@ -33,27 +33,30 @@ class ir_model_fields(osv.osv):
if domain[0] == 'model_id' and domain[2] and type(domain[2]) != list: if domain[0] == 'model_id' and domain[2] and type(domain[2]) != list:
model_domain += [('model_id', 'in', map(int, domain[2][1:-1].split(',')))] model_domain += [('model_id', 'in', map(int, domain[2][1:-1].split(',')))]
else: else:
model_domain += domain
model_domain.append(domain)
return super(ir_model_fields, self).search(cr, uid, model_domain, offset=offset, limit=limit, order=order, context=context, count=count) return super(ir_model_fields, self).search(cr, uid, model_domain, offset=offset, limit=limit, order=order, context=context, count=count)
ir_model_fields() ir_model_fields()
class mass_object(osv.osv):
class mass_object(orm.Model):
_name = "mass.object" _name = "mass.object"
_columns = { _columns = {
'name' : fields.char("Name", size=64, required=True, select=1), 'name' : fields.char("Name", size=64, required=True, select=1),
'model_id' : fields.many2one('ir.model', 'Model', required=True, select=1), 'model_id' : fields.many2one('ir.model', 'Model', required=True, select=1),
'field_ids' : fields.many2many('ir.model.fields', 'mass_field_rel', 'mass_id', 'field_id', 'Fields'), 'field_ids' : fields.many2many('ir.model.fields', 'mass_field_rel', 'mass_id', 'field_id', 'Fields'),
'ref_ir_act_window':fields.many2one('ir.actions.act_window', 'Sidebar action', readonly=True,
help="Sidebar action to make this template available on records "
"of the related document model"),
'ref_ir_value':fields.many2one('ir.values', 'Sidebar button', readonly=True,
'ref_ir_act_window':fields.many2one('ir.actions.act_window', 'Sidebar Action', readonly=True,
help="Sidebar action to make this template available on records \
of the related document model"),
'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_list': fields.char('Model List', size=256)
} }
_sql_constraints = [
('name_uniq', 'unique (name)', _('Name must be unique!')),
]
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:
@ -63,9 +66,8 @@ class mass_object(osv.osv):
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)])
if model_ids:
model_list += model_ids
model_ids = model_obj.search(cr, uid, [('model', '=', key)], context=context)
model_list += model_ids
return {'value': {'model_list': str(model_list)}} return {'value': {'model_list': str(model_list)}}
def create_action(self, cr, uid, ids, context=None): def create_action(self, cr, uid, ids, context=None):
@ -112,6 +114,16 @@ class mass_object(osv.osv):
raise osv.except_osv(_("Warning"), _("Deletion of the action record failed.")) raise osv.except_osv(_("Warning"), _("Deletion of the action record failed."))
return True return True
mass_object()
def unlink(self, cr, uid, ids, context=None):
self.unlink_action(cr, uid, ids, context)
return super(mass_object, self).unlink(cr, uid, ids, context)
def copy(self, cr, uid, record_id, default=None, context=None):
if default is None:
default = {}
default.update({'name':'','field_ids': []})
return super(mass_object, self).copy(cr, uid, record_id, default, context)
mass_object()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

2
mass_editing/security/ir.model.access.csv

@ -1,2 +1,2 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_mass_editing_normal_user","mass.editing.normal.user","model_mass_object","base.group_user",1,1,1,0
"access_mass_editing_normal_user","mass.editing.normal.user","model_mass_object","base.group_user",1,0,0,0

16
mass_editing/wizard/mass_editing_wizard.py

@ -19,12 +19,11 @@
# #
############################################################################## ##############################################################################
from osv import osv
from osv import fields
from openerp.osv import orm, fields
import openerp.tools as tools
from lxml import etree from lxml import etree
import tools
class mass_editing_wizard(osv.osv_memory):
class mass_editing_wizard(orm.TransientModel):
_name = 'mass.editing.wizard' _name = 'mass.editing.wizard'
_columns = { _columns = {
@ -51,11 +50,10 @@ class mass_editing_wizard(osv.osv_memory):
etree.SubElement(xml_group, 'field', {'name': "selection__" + field.name, 'colspan': '2', 'nolabel':'1'}) etree.SubElement(xml_group, 'field', {'name': "selection__" + field.name, 'colspan': '2', 'nolabel':'1'})
etree.SubElement(xml_group, 'field', {'name': field.name, 'colspan':'4', 'nolabel':'1', 'attrs':"{'invisible':[('selection__" + field.name + "','=','remove_m2m')]}"}) etree.SubElement(xml_group, 'field', {'name': field.name, 'colspan':'4', 'nolabel':'1', 'attrs':"{'invisible':[('selection__" + field.name + "','=','remove_m2m')]}"})
elif field.ttype == "many2one": elif field.ttype == "many2one":
if field_info:
all_fields["selection__" + field.name] = {'type':'selection', 'string': field_info[field.name]['string'], 'selection':[('set', 'Set'), ('remove', 'Remove')]}
all_fields[field.name] = {'type':field.ttype, 'string': field.field_description, 'relation': field.relation}
etree.SubElement(xml_group, 'field', {'name': "selection__" + field.name, 'colspan':'2'})
etree.SubElement(xml_group, 'field', {'name': field.name, 'nolabel':'1', 'colspan':'2', 'attrs':"{'invisible':[('selection__" + field.name + "','=','remove')]}"})
all_fields["selection__" + field.name] = {'type':'selection', 'string': field_info[field.name]['string'], 'selection':[('set', 'Set'), ('remove', 'Remove')]}
all_fields[field.name] = {'type':field.ttype, 'string': field.field_description, 'relation': field.relation}
etree.SubElement(xml_group, 'field', {'name': "selection__" + field.name, 'colspan':'2'})
etree.SubElement(xml_group, 'field', {'name': field.name, 'nolabel':'1', 'colspan':'2', 'attrs':"{'invisible':[('selection__" + field.name + "','=','remove')]}"})
elif field.ttype == "char": elif field.ttype == "char":
all_fields["selection__" + field.name] = {'type':'selection', 'string': field_info[field.name]['string'], 'selection':[('set', 'Set'), ('remove', 'Remove')]} all_fields["selection__" + field.name] = {'type':'selection', 'string': field_info[field.name]['string'], 'selection':[('set', 'Set'), ('remove', 'Remove')]}
all_fields[field.name] = {'type':field.ttype, 'string': field.field_description, 'size': field.size or 256} all_fields[field.name] = {'type':field.ttype, 'string': field.field_description, 'size': field.size or 256}

Loading…
Cancel
Save