diff options
| author | Stephane Wirtel <stephane@tinyerp.com> | 2009-01-06 15:36:21 +0100 |
|---|---|---|
| committer | Stephane Wirtel <stephane@tinyerp.com> | 2009-01-06 15:36:21 +0100 |
| commit | acdff83c9b082f4c305b58492eb4a5e4d27194fb (patch) | |
| tree | 0803cc5a44bea7c5c21d4c2d71e07ea00ebcef79 /bin/addons/base/module/module.py | |
| parent | 271403417c32c2420affdbdddf48ef75dc495865 (diff) | |
[IMP] Add the certificat notion for the modules
bzr revid: stephane@tinyerp.com-20090106143621-dobpok2qm0jiooec
Diffstat (limited to 'bin/addons/base/module/module.py')
| -rw-r--r-- | bin/addons/base/module/module.py | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/bin/addons/base/module/module.py b/bin/addons/base/module/module.py index ce9e7683e16..69dd7408a59 100644 --- a/bin/addons/base/module/module.py +++ b/bin/addons/base/module/module.py @@ -176,6 +176,7 @@ class module(osv.osv): 'menus_by_module': fields.function(_get_views, method=True, string='Menus', type='text', multi="meta", store=True), 'reports_by_module': fields.function(_get_views, method=True, string='Reports', type='text', multi="meta", store=True), 'views_by_module': fields.function(_get_views, method=True, string='Views', type='text', multi="meta", store=True), + 'certificat' : fields.char('Certificat', size=64, readonly=True), } _defaults = { @@ -186,7 +187,29 @@ class module(osv.osv): _order = 'name' _sql_constraints = [ - ('name_uniq', 'unique (name)', 'The name of the module must be unique !') + ('name_uniq', 'unique (name)', 'The name of the module must be unique !'), + ('certificat_uniq', 'unique (certificat)', 'The certificat ID of the module must be unique !') + ] + + def _check_certificat(self, cr, uid, ids): + if not ids: + return True + + logger = netsvc.Logger() + for mod in self.browse(cr, uid, ids): + if not mod.certificat: + logger.notifyChannel('', netsvc.LOG_WARNING, 'module %s: no certificat' % mod.name) + else: + try: + val = long(mod.certificat) % 97 == 29 + if not val: + raise Exception('Invalid Certificat') + except Exception, ex: + return False + return True + + _constraints = [ + (_check_certificat, "Your certificat is wrong !", ['certificat']), ] def unlink(self, cr, uid, ids, context=None): @@ -309,6 +332,7 @@ class module(osv.osv): 'author': terp.get('author', 'Unknown'), 'website': terp.get('website', ''), 'license': terp.get('license', 'GPL-2'), + 'certificat': terp.get('certificat', ''), }) cr.execute('DELETE FROM ir_module_module_dependency WHERE module_id = %s', (id,)) self._update_dependencies(cr, uid, ids[0], terp.get('depends', [])) @@ -328,6 +352,7 @@ class module(osv.osv): 'author': terp.get('author', 'Unknown'), 'website': terp.get('website', ''), 'license': terp.get('license', 'GPL-2'), + 'certificat': terp.get('certificat', ''), }) res[1] += 1 self._update_dependencies(cr, uid, id, terp.get('depends', [])) @@ -408,6 +433,7 @@ class module(osv.osv): 'author': terp.get('author', 'Unknown'), 'website': terp.get('website', ''), 'license': terp.get('license', 'GPL-2'), + 'certificat': terp.get('certificat', ''), }) cr.execute('DELETE FROM ir_module_module_dependency ' \ 'WHERE module_id = %s', (mod.id,)) @@ -484,8 +510,7 @@ class module(osv.osv): for mod in self.browse(cr, uid, [module_id]): logger.notifyChannel("init", netsvc.LOG_WARNING, 'module %s: description is empty !' % (mod.name)) - return module_id - + return module_id module() |
