From aa478ca6fae175b91ef4d37a3cb05430f41429a2 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Wed, 10 Aug 2016 09:10:43 -0500 Subject: [PATCH] [FIX+IMP] PEP8 + conflicts + Combined methods --- base_export_manager/models/res_users.py | 30 ++++++++----------- .../static/src/js/base_export_manager.js | 5 ++-- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/base_export_manager/models/res_users.py b/base_export_manager/models/res_users.py index 2441dec..759bf26 100644 --- a/base_export_manager/models/res_users.py +++ b/base_export_manager/models/res_users.py @@ -8,21 +8,15 @@ from openerp import api, models class ResUsers(models.Model): _inherit = 'res.users' - - @api.v7 - def get_export_models(self, cr, uid): - return self.fetch_export_models(cr, uid) - - @api.v8 - def get_export_models(self): - uid = self.id or self.env.uid - return self.fetch_export_models(self.env.cr, uid) - - def fetch_export_models(self, cr, uid): - groups_id = [group.id for group in self.browse(cr, uid, uid).groups_id] - accessobj = self.pool['ir.model.access'] - accessobj_ids = accessobj.search(cr, uid, [('perm_export','=',True),('group_id','in',groups_id)]) - model_names = [access_obj.model_id.model for access_obj in accessobj.browse(cr, uid, accessobj_ids)] - #make distinct value in list - model_names = list(set(model_names)) - return model_names \ No newline at end of file + + @api.model + def fetch_export_models(self): + accessobj = self.env['ir.model.access'] + accessobj_ids = accessobj.search([ + ('perm_export', '=', True), + ('group_id', 'in', self.env.user.groups_id.ids), + ]) + model_names = [ + access_obj.model_id.model for access_obj in accessobj_ids + ] + return list(set(model_names)) diff --git a/base_export_manager/static/src/js/base_export_manager.js b/base_export_manager/static/src/js/base_export_manager.js index e48fd4f..a5a642e 100644 --- a/base_export_manager/static/src/js/base_export_manager.js +++ b/base_export_manager/static/src/js/base_export_manager.js @@ -13,6 +13,7 @@ odoo.define('base_export_manager.base_export_manager', function(require) { var Sidebar = require('web.Sidebar'); var _t = core._t; var Session = require('web.Session'); + var session = require('web.session'); DataExport.include({ @@ -39,7 +40,7 @@ odoo.define('base_export_manager.base_export_manager', function(require) { return $.when().resolve(false); } var Users = new Model('res.users'); - var export_models = Users.call('get_export_models', []); + var export_models = Users.call('fetch_export_models', []); return export_models; }, }); @@ -51,7 +52,7 @@ odoo.define('base_export_manager.base_export_manager', function(require) { }, is_export_manager: function () { var self = this; - $.when(Session.get_export_models()).then(function + $.when(self.session.get_export_models()).then(function (export_models) { self.export_models=export_models; });