Skip to content

Commit

Permalink
[REF] flake8 for 'mass_editing', 'auth_admin_passkey', 'disable_opene…
Browse files Browse the repository at this point in the history
…rp_online' modules;
  • Loading branch information
legalsylvain authored and yvaucher committed Jul 7, 2014
2 parents 17e575c + e79795f commit 5846255
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 121 deletions.
2 changes: 1 addition & 1 deletion auth_admin_passkey/tests/test_auth_admin_passkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_06_passkey_login_demo_succeed(self):
Test the correct behaviour of login with 'bad_login' / 'admin'"""
exception_raised = False
try:
res = self.ru_obj.authenticate(self.db, 'bad_login', 'admin', {})
self.ru_obj.authenticate(self.db, 'bad_login', 'admin', {})
except:
exception_raised = True
self.assertEqual(
Expand Down
19 changes: 10 additions & 9 deletions disable_openerp_online/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#
##############################################################################
{
"name" : "Remove openerp.com bindings",
"version" : "1.1",
"author" : "Therp BV",
"name": "Remove openerp.com bindings",
"version": "1.1",
"author": "Therp BV",
"complexity": "normal",
"description": """
This module deactivates all bindings to openerp.com that
Expand All @@ -30,14 +30,15 @@
* update notifier code is deactivated and the function is overwritten
* apps and updates menu items in settings are removed
* help and account menu items in user menu are removed
* prevent lookup of OPW for current database uuid and resulting 'unsupported' warning
* prevent lookup of OPW for current database uuid and resulting"""
""" 'unsupported' warning
""",
"category" : "",
"depends" : [
"category": "",
"depends": [
'base',
'mail',
],
"data" : [
"data": [
'data/ir_ui_menu.xml',
'data/ir_cron.xml',
],
Expand All @@ -51,7 +52,7 @@
],
"auto_install": False,
"installable": True,
"external_dependencies" : {
'python' : [],
"external_dependencies": {
'python': [],
},
}
28 changes: 17 additions & 11 deletions mass_editing/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
##############################################################################
#
# 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
# it under the terms of the GNU General Public License as published by
Expand All @@ -19,16 +20,21 @@
#
##############################################################################
{
"name" : "Mass Editing",
"version" : "1.3",
"author" : "Serpent Consulting Services",
"category" : "Tools",
"website" : "http://www.serpentcs.com",
"description": """This module provides the functionality to add, update or remove the values of more than one records on the fly at the same time.
You can configure mass editing for any OpenERP model.
The video explaining the features and how-to for OpenERP Version 6 is here http://t.co/wukYMx1A
The video explaining the features and how-to for OpenERP Version 7 is here : http://www.youtube.com/watch?v=9BH0o74A748&feature=youtu.be
For more details/customization/feedback contact us on [email protected].
"name": "Mass Editing",
"version": "1.3",
"author": "Serpent Consulting Services",
"category": "Tools",
"website": "http://www.serpentcs.com",
"description": """
This module provides the functionality to add, update or remove the values"""
"""of more than one records on the fly at the same time.
You can configure mass editing for any OpenERP model.
The video explaining the features and how-to for OpenERP Version 6"""
""" is here http://t.co/wukYMx1A
The video explaining the features and how-to for OpenERP Version 7 is"""
""" here : http://www.youtube.com/watch?v=9BH0o74A748&feature=youtu.be
For more details/customization/feedback contact us on"""
""" [email protected].
""",
'depends': ['base'],
'data': [
Expand Down
112 changes: 66 additions & 46 deletions mass_editing/mass_editing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
##############################################################################
#
# 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
# it under the terms of the GNU General Public License as published by
Expand All @@ -19,37 +20,48 @@
#
##############################################################################

from openerp.osv import orm, fields
import openerp.tools
from openerp.osv import orm, fields, osv
from openerp.tools.translate import _
from lxml import etree


class ir_model_fields(orm.Model):
_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):
model_domain = []
for domain in args:
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(',')))]
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(',')))]
else:
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()


class mass_object(orm.Model):
_name = "mass.object"

_columns = {
'name' : fields.char("Name", size=64, 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'),
'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"),
'name': fields.char("Name", size=64, 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'),
'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"),
'model_ids': fields.many2many('ir.model', string='Model List')
}

Expand All @@ -58,60 +70,68 @@ class mass_object(orm.Model):
]

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:
return {'value': {'model_ids': [(6, 0, [])]}}
model_ids = [model_id]
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:
for key, val in active_model_obj._inherits.items():
found_model_ids = model_obj.search(cr, uid, [('model', '=', key)], context=context)
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):
vals = {}
action_obj = self.pool.get('ir.actions.act_window')
data_obj = self.pool.get('ir.model.data')
ir_values_obj = self.pool.get('ir.values')
for data in self.browse(cr, uid, ids, context=context):
src_obj = data.model_id.model
button_name = _('Mass Editing (%s)') % data.name
vals['ref_ir_act_window'] = action_obj.create(cr, uid, {
'name': button_name,
'type': 'ir.actions.act_window',
'res_model': 'mass.editing.wizard',
'src_model': src_obj,
'view_type': 'form',
'context': "{'mass_editing_object' : %d}" % (data.id),
'view_mode':'form,tree',
'target': 'new',
'auto_refresh':1
}, context)
'name': button_name,
'type': 'ir.actions.act_window',
'res_model': 'mass.editing.wizard',
'src_model': src_obj,
'view_type': 'form',
'context': "{'mass_editing_object' : %d}" % (data.id),
'view_mode': 'form,tree',
'target': 'new',
'auto_refresh': 1,
}, context)
vals['ref_ir_value'] = ir_values_obj.create(cr, uid, {
'name': button_name,
'model': src_obj,
'key2': 'client_action_multi',
'value': "ir.actions.act_window," + str(vals['ref_ir_act_window']),
'object': True,
}, context)
self.write(cr, uid, ids, {
'ref_ir_act_window': vals.get('ref_ir_act_window', False),
'ref_ir_value': vals.get('ref_ir_value', False),
'name': button_name,
'model': src_obj,
'key2': 'client_action_multi',
'value': (
"ir.actions.act_window,"
+ str(vals['ref_ir_act_window'])),
'object': True,
}, context)
self.write(cr, uid, ids, {
'ref_ir_act_window': vals.get('ref_ir_act_window', False),
'ref_ir_value': vals.get('ref_ir_value', False),
}, context)
return True

def unlink_action(self, cr, uid, ids, context=None):
for template in self.browse(cr, uid, ids, context=context):
try:
if template.ref_ir_act_window:
self.pool.get('ir.actions.act_window').unlink(cr, uid, template.ref_ir_act_window.id, context)
self.pool.get('ir.actions.act_window').unlink(
cr, uid, template.ref_ir_act_window.id, context)
if template.ref_ir_value:
ir_values_obj = self.pool.get('ir.values')
ir_values_obj.unlink(cr, uid, template.ref_ir_value.id, context)
ir_values_obj.unlink(
cr, uid, template.ref_ir_value.id, context)
except:
raise osv.except_osv(_("Warning"), _("Deletion of the action record failed."))
raise osv.except_osv(
_("Warning"),
_("Deletion of the action record failed."))
return True

def unlink(self, cr, uid, ids, context=None):
Expand All @@ -121,9 +141,9 @@ def unlink(self, cr, uid, ids, context=None):
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)
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:
Loading

0 comments on commit 5846255

Please sign in to comment.