# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # # 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 . # ############################################################################## import wizard import math from osv import osv from tools.misc import UpdateableStr import pooler def _is_pair(x): return not x%2 def _get_ean_key(string): if not string or string=='': return '0' if len(string)!=12: return '0' sum=0 for i in range(12): if _is_pair(i): sum+=int(string[i]) else: sum+=3*int(string[i]) return str(int(math.ceil(sum/10.0)*10-sum)) #FIXME: this is not concurrency safe !!!! _check_arch = UpdateableStr() _check_fields = {} def _check_key(self, cr, uid, data, context): partner_table=pooler.get_pool(cr.dbname).get('res.partner') partners = partner_table.browse(cr, uid, data['ids']) _check_arch_lst=['', '
', '