[ADD] Migrated <mass_editing> for Odoo
parent
f83737f6e8
commit
27970ad2ab
|
@ -2,7 +2,8 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# This module uses OpenERP, Open Source Management Solution Framework.
|
# This module uses OpenERP, Open Source Management Solution Framework.
|
||||||
# Copyright (C) 2012-Today Serpent Consulting Services (<http://www.serpentcs.com>)
|
# Copyright (C):
|
||||||
|
# 2012-Today Serpent Consulting Services (<http://www.serpentcs.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -19,6 +20,5 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import mass_editing_wizard
|
from . import models
|
||||||
|
from . import wizard
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
|
@ -23,27 +23,28 @@
|
||||||
"name": "Mass Editing",
|
"name": "Mass Editing",
|
||||||
"version": "1.3",
|
"version": "1.3",
|
||||||
"author": "Serpent Consulting Services",
|
"author": "Serpent Consulting Services",
|
||||||
|
"contributors": [
|
||||||
|
"Oihane Crucelaegui <oihanecrucelaegi@gmail.com>",
|
||||||
|
],
|
||||||
"category": "Tools",
|
"category": "Tools",
|
||||||
"website": "http://www.serpentcs.com",
|
"website": "http://www.serpentcs.com",
|
||||||
"description": """
|
"description": """
|
||||||
This module provides the functionality to add, update or remove the values"""
|
This module provides the functionality to add, update or remove the values
|
||||||
"""of more than one records on the fly at the same time.
|
of more than one records on the fly at the same time.
|
||||||
You can configure mass editing for any OpenERP model.
|
You can configure mass editing for any OpenERP model.
|
||||||
The video explaining the features and how-to for OpenERP Version 6"""
|
The video explaining the features and how-to for OpenERP Version 6
|
||||||
""" is here http://t.co/wukYMx1A
|
is here http://t.co/wukYMx1A
|
||||||
The video explaining the features and how-to for OpenERP Version 7 is"""
|
The video explaining the features and how-to for OpenERP Version 7 is
|
||||||
""" here : http://www.youtube.com/watch?v=9BH0o74A748&feature=youtu.be
|
here : http://www.youtube.com/watch?v=9BH0o74A748&feature=youtu.be
|
||||||
For more details/customization/feedback contact us on"""
|
For more details/customization/feedback contact us on
|
||||||
""" contact@serpentcs.com.
|
contact@serpentcs.com.
|
||||||
""",
|
""",
|
||||||
'depends': ['base'],
|
'depends': ['base'],
|
||||||
'data': [
|
'data': [
|
||||||
"security/ir.model.access.csv",
|
"security/ir.model.access.csv",
|
||||||
'mass_editing_view.xml',
|
'views/mass_editing_view.xml',
|
||||||
],
|
],
|
||||||
'installable': False,
|
'installable': True,
|
||||||
'application': True,
|
'application': True,
|
||||||
'auto_install': False,
|
'auto_install': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
|
@ -2,7 +2,8 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# This module uses OpenERP, Open Source Management Solution Framework.
|
# This module uses OpenERP, Open Source Management Solution Framework.
|
||||||
# Copyright (C) 2012-Today Serpent Consulting Services (<http://www.serpentcs.com>)
|
# Copyright (C):
|
||||||
|
# 2012-Today Serpent Consulting Services (<http://www.serpentcs.com>)
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -19,8 +20,4 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import mass_editing
|
from . import mass_editing
|
||||||
import wizard
|
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
||||||
|
|
|
@ -20,11 +20,12 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from openerp.osv import orm, fields, osv
|
from openerp import SUPERUSER_ID
|
||||||
|
from openerp.osv import orm, fields
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
|
|
||||||
class ir_model_fields(orm.Model):
|
class IrModelFields(orm.Model):
|
||||||
_inherit = 'ir.model.fields'
|
_inherit = 'ir.model.fields'
|
||||||
|
|
||||||
def search(
|
def search(
|
||||||
|
@ -38,14 +39,12 @@ class ir_model_fields(orm.Model):
|
||||||
'model_id', 'in', map(int, domain[2][1:-1].split(',')))]
|
'model_id', 'in', map(int, domain[2][1:-1].split(',')))]
|
||||||
else:
|
else:
|
||||||
model_domain.append(domain)
|
model_domain.append(domain)
|
||||||
return super(ir_model_fields, self).search(
|
return super(IrModelFields, self).search(
|
||||||
cr, uid, model_domain, offset=offset, limit=limit, order=order,
|
cr, uid, model_domain, offset=offset, limit=limit, order=order,
|
||||||
context=context, count=count)
|
context=context, count=count)
|
||||||
|
|
||||||
ir_model_fields()
|
|
||||||
|
|
||||||
|
class MassObject(orm.Model):
|
||||||
class mass_object(orm.Model):
|
|
||||||
_name = "mass.object"
|
_name = "mass.object"
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
|
@ -75,7 +74,7 @@ class mass_object(orm.Model):
|
||||||
if not model_id:
|
if not model_id:
|
||||||
return {'value': {'model_ids': [(6, 0, [])]}}
|
return {'value': {'model_ids': [(6, 0, [])]}}
|
||||||
model_ids = [model_id]
|
model_ids = [model_id]
|
||||||
model_obj = self.pool.get('ir.model')
|
model_obj = self.pool['ir.model']
|
||||||
active_model_obj = self.pool.get(model_obj.browse(
|
active_model_obj = self.pool.get(model_obj.browse(
|
||||||
cr, uid, model_id).model)
|
cr, uid, model_id).model)
|
||||||
if active_model_obj._inherits:
|
if active_model_obj._inherits:
|
||||||
|
@ -87,12 +86,12 @@ class mass_object(orm.Model):
|
||||||
|
|
||||||
def create_action(self, cr, uid, ids, context=None):
|
def create_action(self, cr, uid, ids, context=None):
|
||||||
vals = {}
|
vals = {}
|
||||||
action_obj = self.pool.get('ir.actions.act_window')
|
action_obj = self.pool['ir.actions.act_window']
|
||||||
ir_values_obj = self.pool.get('ir.values')
|
ir_values_obj = self.pool['ir.values']
|
||||||
for data in self.browse(cr, uid, ids, context=context):
|
for data in self.browse(cr, uid, ids, context=context):
|
||||||
src_obj = data.model_id.model
|
src_obj = data.model_id.model
|
||||||
button_name = _('Mass Editing (%s)') % data.name
|
button_name = _('Mass Editing (%s)') % data.name
|
||||||
vals['ref_ir_act_window'] = action_obj.create(cr, uid, {
|
vals['ref_ir_act_window'] = action_obj.create(cr, SUPERUSER_ID, {
|
||||||
'name': button_name,
|
'name': button_name,
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'res_model': 'mass.editing.wizard',
|
'res_model': 'mass.editing.wizard',
|
||||||
|
@ -103,7 +102,7 @@ class mass_object(orm.Model):
|
||||||
'target': 'new',
|
'target': 'new',
|
||||||
'auto_refresh': 1,
|
'auto_refresh': 1,
|
||||||
}, context)
|
}, context)
|
||||||
vals['ref_ir_value'] = ir_values_obj.create(cr, uid, {
|
vals['ref_ir_value'] = ir_values_obj.create(cr, SUPERUSER_ID, {
|
||||||
'name': button_name,
|
'name': button_name,
|
||||||
'model': src_obj,
|
'model': src_obj,
|
||||||
'key2': 'client_action_multi',
|
'key2': 'client_action_multi',
|
||||||
|
@ -122,28 +121,28 @@ class mass_object(orm.Model):
|
||||||
for template in self.browse(cr, uid, ids, context=context):
|
for template in self.browse(cr, uid, ids, context=context):
|
||||||
try:
|
try:
|
||||||
if template.ref_ir_act_window:
|
if template.ref_ir_act_window:
|
||||||
self.pool.get('ir.actions.act_window').unlink(
|
act_window_obj = self.pool['ir.actions.act_window']
|
||||||
cr, uid, template.ref_ir_act_window.id, context)
|
act_window_obj.unlink(
|
||||||
|
cr, SUPERUSER_ID, [template.ref_ir_act_window.id],
|
||||||
|
context=context)
|
||||||
if template.ref_ir_value:
|
if template.ref_ir_value:
|
||||||
ir_values_obj = self.pool.get('ir.values')
|
ir_values_obj = self.pool['ir.values']
|
||||||
ir_values_obj.unlink(
|
ir_values_obj.unlink(
|
||||||
cr, uid, template.ref_ir_value.id, context)
|
cr, SUPERUSER_ID, template.ref_ir_value.id,
|
||||||
|
context=context)
|
||||||
except:
|
except:
|
||||||
raise osv.except_osv(
|
raise orm.except_orm(
|
||||||
_("Warning"),
|
_("Warning"),
|
||||||
_("Deletion of the action record failed."))
|
_("Deletion of the action record failed."))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def unlink(self, cr, uid, ids, context=None):
|
def unlink(self, cr, uid, ids, context=None):
|
||||||
self.unlink_action(cr, uid, ids, context)
|
self.unlink_action(cr, uid, ids, context=context)
|
||||||
return super(mass_object, self).unlink(cr, uid, ids, context)
|
return super(MassObject, self).unlink(cr, uid, ids, context=context)
|
||||||
|
|
||||||
def copy(self, cr, uid, record_id, default=None, context=None):
|
def copy(self, cr, uid, record_id, default=None, context=None):
|
||||||
if default is None:
|
if default is None:
|
||||||
default = {}
|
default = {}
|
||||||
default.update({'name': '', 'field_ids': []})
|
default.update({'name': '', 'field_ids': []})
|
||||||
return super(mass_object, self).copy(
|
return super(MassObject, self).copy(
|
||||||
cr, uid, record_id, default, context)
|
cr, uid, record_id, default, context=context)
|
||||||
|
|
||||||
mass_object()
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# This module uses OpenERP, Open Source Management Solution Framework.
|
||||||
|
# Copyright (C):
|
||||||
|
# 2012-Today Serpent Consulting Services (<http://www.serpentcs.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
from . import mass_editing_wizard
|
|
@ -25,19 +25,16 @@ import openerp.tools as tools
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
|
|
||||||
class mass_editing_wizard(orm.TransientModel):
|
class MassEditingWizard(orm.TransientModel):
|
||||||
_name = 'mass.editing.wizard'
|
_name = 'mass.editing.wizard'
|
||||||
|
|
||||||
_columns = {
|
|
||||||
}
|
|
||||||
|
|
||||||
def fields_view_get(
|
def fields_view_get(
|
||||||
self, cr, uid, view_id=None, view_type='form', context=None,
|
self, cr, uid, view_id=None, view_type='form', context=None,
|
||||||
toolbar=False, submenu=False):
|
toolbar=False, submenu=False):
|
||||||
result = super(mass_editing_wizard, self).fields_view_get(
|
result = super(MassEditingWizard, self).fields_view_get(
|
||||||
cr, uid, view_id, view_type, context, toolbar, submenu)
|
cr, uid, view_id, view_type, context, toolbar, submenu)
|
||||||
if context.get('mass_editing_object'):
|
if context.get('mass_editing_object'):
|
||||||
mass_object = self.pool.get('mass.object')
|
mass_object = self.pool['mass.object']
|
||||||
editing_data = mass_object.browse(
|
editing_data = mass_object.browse(
|
||||||
cr, uid, context.get('mass_editing_object'), context)
|
cr, uid, context.get('mass_editing_object'), context)
|
||||||
all_fields = {}
|
all_fields = {}
|
||||||
|
@ -47,7 +44,7 @@ class mass_editing_wizard(orm.TransientModel):
|
||||||
etree.SubElement(xml_group, 'label', {
|
etree.SubElement(xml_group, 'label', {
|
||||||
'string': '', 'colspan': '2'})
|
'string': '', 'colspan': '2'})
|
||||||
xml_group = etree.SubElement(xml_form, 'group', {'colspan': '4'})
|
xml_group = etree.SubElement(xml_form, 'group', {'colspan': '4'})
|
||||||
model_obj = self.pool.get(context.get('active_model'))
|
model_obj = self.pool[context.get('active_model')]
|
||||||
field_info = model_obj.fields_get(cr, uid, [], context)
|
field_info = model_obj.fields_get(cr, uid, [], context)
|
||||||
for field in editing_data.field_ids:
|
for field in editing_data.field_ids:
|
||||||
if field.ttype == "many2many":
|
if field.ttype == "many2many":
|
||||||
|
@ -174,11 +171,12 @@ class mass_editing_wizard(orm.TransientModel):
|
||||||
etree.SubElement(
|
etree.SubElement(
|
||||||
xml_form, 'separator', {'string': '', 'colspan': '4'})
|
xml_form, 'separator', {'string': '', 'colspan': '4'})
|
||||||
xml_group3 = etree.SubElement(xml_form, 'footer', {})
|
xml_group3 = etree.SubElement(xml_form, 'footer', {})
|
||||||
etree.SubElement(xml_group3, 'button', {
|
|
||||||
'string': 'Close', 'icon': "gtk-close", 'special': 'cancel'})
|
|
||||||
etree.SubElement(xml_group3, 'button', {
|
etree.SubElement(xml_group3, 'button', {
|
||||||
'string': 'Apply', 'icon': "gtk-execute",
|
'string': 'Apply', 'icon': "gtk-execute",
|
||||||
'type': 'object', 'name': "action_apply"})
|
'type': 'object', 'name': "action_apply",
|
||||||
|
'class': "oe_highlight"})
|
||||||
|
etree.SubElement(xml_group3, 'button', {
|
||||||
|
'string': 'Close', 'icon': "gtk-close", 'special': 'cancel'})
|
||||||
root = xml_form.getroottree()
|
root = xml_form.getroottree()
|
||||||
result['arch'] = etree.tostring(root)
|
result['arch'] = etree.tostring(root)
|
||||||
result['fields'] = all_fields
|
result['fields'] = all_fields
|
||||||
|
@ -207,11 +205,8 @@ class mass_editing_wizard(orm.TransientModel):
|
||||||
if dict:
|
if dict:
|
||||||
model_obj.write(
|
model_obj.write(
|
||||||
cr, uid, context.get('active_ids'), dict, context)
|
cr, uid, context.get('active_ids'), dict, context)
|
||||||
result = super(mass_editing_wizard, self).create(cr, uid, {}, context)
|
result = super(MassEditingWizard, self).create(cr, uid, {}, context)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def action_apply(self, cr, uid, ids, context=None):
|
def action_apply(self, cr, uid, ids, context=None):
|
||||||
return {'type': 'ir.actions.act_window_close'}
|
return {'type': 'ir.actions.act_window_close'}
|
||||||
|
|
||||||
mass_editing_wizard()
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
Loading…
Reference in New Issue