Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions mass_editing/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/server-tools/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed `feedback
<https://github.com/OCA/
server-tools/issues/new?body=module:%20
server-tools%0Aversion:%20
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
help us smashing it by providing a detailed and welcomed feedback.

Credits
=======
Expand Down
2 changes: 1 addition & 1 deletion mass_editing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
Expand Down
8 changes: 5 additions & 3 deletions mass_editing/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# -*- coding: utf-8 -*-
# © 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'Mass Editing',
'version': '9.0.1.0.0',
'version': '10.0.1.0.0',
'author': 'Serpent Consulting Services Pvt. Ltd., '
'Odoo Community Association (OCA)',
'contributors': [
'Oihane Crucelaegui <oihanecrucelaegi@gmail.com>',
'Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>',
'Jay Vora <jay.vora@serpentcs.com>'
],
'category': 'Tools',
'website': 'http://www.serpentcs.com',
Expand All @@ -20,7 +22,7 @@
'security/ir.model.access.csv',
'views/mass_editing_view.xml',
],
'installable': False,
'installable': True,
'application': False,
'auto_install': False,
}
6 changes: 3 additions & 3 deletions mass_editing/hooks.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
# © 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


def uninstall_hook(cr, registry):
cr.execute("""SELECT id FROM ir_act_window
WHERE res_model = 'mass.editing.wizard'""")
for res in cr.dictfetchall():
value = 'ir.actions.act_window,%s' % res.get('id')
cr.execute("DELETE FROM ir_values WHERE value = '%s'" % value)
cr.execute("DELETE FROM ir_values WHERE value = %s", (value, ))
return True
3 changes: 1 addition & 2 deletions mass_editing/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import ir_model_fields
from . import mass_object
23 changes: 0 additions & 23 deletions mass_editing/models/ir_model_fields.py

This file was deleted.

39 changes: 19 additions & 20 deletions mass_editing/models/mass_object.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# -*- coding: utf-8 -*-
# © 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp.exceptions import UserError
from openerp import api, fields, models, _
from odoo import api, fields, models, _


class MassObject(models.Model):
_name = "mass.object"
_description = "Mass Editing Object"

name = fields.Char('Name', required=True, select=1)
name = fields.Char('Name', required=True, index=1)
model_id = fields.Many2one('ir.model', 'Model', required=True,
help="Model is used for Selecting Fields. "
"This is editable until Sidebar menu "
Expand All @@ -28,7 +27,8 @@ class MassObject(models.Model):
readonly=True,
help="Sidebar button to open "
"the sidebar action.")
model_list = fields.Char('Model List')
model_ids = fields.Many2many('ir.model', 'mass_model_rel',
'mass_id', 'model_id', 'Model List')

_sql_constraints = [
('name_uniq', 'unique (name)', _('Name must be unique!')),
Expand All @@ -37,17 +37,17 @@ class MassObject(models.Model):
@api.onchange('model_id')
def _onchange_model_id(self):
self.field_ids = [(6, 0, [])]
model_list = []
model_ids = []
if self.model_id:
model_obj = self.env['ir.model']
model_list = [self.model_id.id]
model_ids = [self.model_id.id]
active_model_obj = self.env[self.model_id.model]
if active_model_obj._inherits:
keys = active_model_obj._inherits.keys()
inherits_model_list = model_obj.search([('model', 'in', keys)])
model_list.extend((inherits_model_list and
inherits_model_list.ids or []))
self.model_list = model_list
inherits_model_ids = model_obj.search([('model', 'in', keys)])
model_ids.extend((inherits_model_ids and
inherits_model_ids.ids or []))
self.model_ids = [(6, 0, model_ids)]

@api.multi
def create_action(self):
Expand All @@ -67,7 +67,9 @@ def create_action(self):
'target': 'new',
'auto_refresh': 1,
}).id
vals['ref_ir_value_id'] = self.env['ir.values'].create({
# We make sudo as any user with rights in this model should be able
# to create the action, not only admin
vals['ref_ir_value_id'] = self.env['ir.values'].sudo().create({
'name': button_name,
'model': src_obj,
'key2': 'client_action_multi',
Expand All @@ -79,21 +81,18 @@ def create_action(self):

@api.multi
def unlink_action(self):
for mass in self:
try:
if mass.ref_ir_act_window_id:
mass.ref_ir_act_window_id.unlink()
if mass.ref_ir_value_id:
mass.ref_ir_value_id.unlink()
except:
raise UserError(_("Deletion of the action record failed."))
# We make sudo as any user with rights in this model should be able
# to delete the action, not only admin
self.mapped('ref_ir_act_window_id').sudo().unlink()
self.mapped('ref_ir_value_id').sudo().unlink()
return True

@api.multi
def unlink(self):
self.unlink_action()
return super(MassObject, self).unlink()

@api.multi
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
if default is None:
Expand Down
2 changes: 1 addition & 1 deletion mass_editing/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_mass_editing
15 changes: 6 additions & 9 deletions mass_editing/tests/test_mass_editing.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# -*- coding: utf-8 -*-
# © 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import ast

from openerp.tests import common
from openerp.modules import registry
from openerp.addons.mass_editing.hooks import uninstall_hook
from odoo.tests import common
from odoo.modules import registry
from odoo.addons.mass_editing.hooks import uninstall_hook


class TestMassEditing(common.TransactionCase):
Expand Down Expand Up @@ -85,9 +83,8 @@ def test_onchange_model(self):
"""Test whether onchange model_id returns model_id in list"""
new_mass = self.mass_object_model.new({'model_id': self.user_model.id})
new_mass._onchange_model_id()
model_list = ast.literal_eval(new_mass.model_list)
self.assertTrue(self.user_model.id in model_list,
'Onchange model list must contains model_id.')
self.assertTrue(self.user_model.id in new_mass.model_ids.ids,
'Onchange model ids must contains model_id.')

def test_mass_edit_email(self):
"""Test Case for MASS EDITING which will remove and after add
Expand Down
38 changes: 21 additions & 17 deletions mass_editing/views/mass_editing_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@
<field name="model">mass.object</field>
<field name="arch" type="xml">
<form string="Object">
<header>
<button name="create_action"
type="object"
string="Add Sidebar Button"
class="btn-link oe_highlight"
attrs="{'invisible':[('ref_ir_act_window_id','!=',False)]}"
icon="fa-plus"
help="Display a button in the sidebar of related documents to open a composition wizard"/>
<button name="unlink_action"
type="object"
string="Remove Sidebar Button"
class="btn-link oe_highlight" icon="fa-minus"
attrs="{'invisible':[('ref_ir_act_window_id','=',False)]}"
help="Remove the contextual action to use this template on related documents"
widget="statinfo"/>
<field name="ref_ir_act_window_id" invisible="1"/>
</header>
<sheet>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
Expand All @@ -17,31 +34,18 @@
<field name="model_id" required="1" attrs="{'readonly':[('ref_ir_act_window_id','!=',False)]}"/>
</group>
<group>
<field name="model_list" invisible="1"/>
<field name="model_ids" invisible="1"/>
</group>
</group>
</div>
<div class="oe_right oe_button_box" name="buttons">
<field name="ref_ir_act_window_id" invisible="1"/>
<button name="create_action"
type="object"
string="Add Sidebar Button"
class="oe_inline oe_stat_button"
attrs="{'invisible':[('ref_ir_act_window_id','!=',False)]}"
icon="fa-plus"
help="Display a button in the sidebar of related documents to open a composition wizard"/>
<button name="unlink_action"
type="object"
string="Remove Sidebar Button"
class="oe_stat_button" icon="fa-minus"
attrs="{'invisible':[('ref_ir_act_window_id','=',False)]}"
help="Remove the contextual action to use this template on related documents"
widget="statinfo"/>


</div>
<notebook colspan="4">
<page string="Fields">
<field name="field_ids" colspan="4" nolabel="1"
domain="[('ttype', 'not in', ['refenrence', 'function']), ('model_id', 'in', model_list)]"/>
domain="[('ttype', 'not in', ['reference', 'function']), ('model_id', 'in', model_ids and model_ids[0][2] or [])]"/>
</page>
<page string="Advanced" attrs="{'invisible':[('ref_ir_act_window_id','=',False)]}">
<group colspan="2" col="2">
Expand Down
2 changes: 1 addition & 1 deletion mass_editing/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import mass_editing_wizard
4 changes: 2 additions & 2 deletions mass_editing/wizard/mass_editing_wizard.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# © 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. (support@serpentcs.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from lxml import etree

import openerp.tools as tools
from openerp import api, models
from odoo import api, models


class MassEditingWizard(models.TransientModel):
Expand Down