diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 104272dcaf4..d30867bd730 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -583,7 +583,7 @@ - + @@ -1508,7 +1508,7 @@ - + diff --git a/addons/account/account_wizard.xml b/addons/account/account_wizard.xml index d5420f34a51..d53ddc5adee 100644 --- a/addons/account/account_wizard.xml +++ b/addons/account/account_wizard.xml @@ -2,7 +2,7 @@ - + diff --git a/addons/account/partner.py b/addons/account/partner.py index c1eac82b99c..a47aae0d792 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -38,7 +38,7 @@ class res_partner(osv.osv): def _credit_debit_get(self, cr, uid, ids, field_names, arg, context): query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) cr.execute(("""select - l.partner_id, a.type, sum(l.debit-l.credit) + l.partner_id, a.type, sum(l.debit-l.credit) from account_move_line l left join @@ -116,6 +116,7 @@ class res_partner(osv.osv): string="Default Supplier Tax", method=True, view_load=True, + domain=[('parent_id','=',False)], help="This tax will be used, instead of the default one for supplier invoices."), 'property_account_tax': fields.property( 'account.tax', @@ -124,6 +125,7 @@ class res_partner(osv.osv): string="Default Tax", method=True, view_load=True, + domain=[('parent_id','=',False)], help="This tax will be used, instead of the default one for customers."), 'property_payment_term': fields.property( 'account.payment.term', diff --git a/addons/account/wizard/wizard_refund.py b/addons/account/wizard/wizard_refund.py index 0b6fa0430a3..c0d4ef6af0f 100644 --- a/addons/account/wizard/wizard_refund.py +++ b/addons/account/wizard/wizard_refund.py @@ -32,7 +32,7 @@ import wizard import pooler sur_form = ''' -
+
+ diff --git a/addons/base_iban/base_iban.py b/addons/base_iban/base_iban.py index 870d7cb7317..d7ccef61ad2 100644 --- a/addons/base_iban/base_iban.py +++ b/addons/base_iban/base_iban.py @@ -31,11 +31,52 @@ import netsvc from osv import fields, osv +def _format_iban(string): + ''' + This function removes all characters from given 'string' that isn't a alpha numeric and converts it to lower case. + ''' + res = "" + for char in string: + if char.isalnum(): + res += char.lower() + return res + class res_partner_bank(osv.osv): _inherit = "res.partner.bank" - _columns = { - 'iban': fields.char('IBAN', size=34, readonly=True, help="International Bank Account Number"), - } + + def create(self, cr, uid, vals, context={}): + #overwrite to format the iban number correctly + if vals.has_key('iban'): + vals['iban'] = _format_iban(vals['iban']) + return super(res_partner_bank, self).create(cr, uid, vals, context) + + def write(self, cr, uid, ids, vals, context={}): + #overwrite to format the iban number correctly + if vals.has_key('iban'): + vals['iban'] = _format_iban(vals['iban']) + return super(res_partner_bank, self).write(cr, uid, ids, vals, context) + + def check_iban(self, cr, uid, ids): + ''' + Check the IBAN number + ''' + for bank_acc in self.browse(cr, uid, ids): + if not bank_acc.iban: + continue + iban =_format_iban(bank_acc.iban) + #the four first digits have to be shifted to the end + iban = iban[4:] + iban[:4] + #letters have to be transformed into numbers (a = 10, b = 11, ...) + iban2 = "" + for char in iban: + if char.isalpha(): + iban2 += str(ord(char)-87) + else: + iban2 += char + #iban is correct if modulo 97 == 1 + if not int(iban2) % 97 == 1: + return False + return True def name_get(self, cr, uid, ids, context=None): res = [] @@ -48,18 +89,50 @@ class res_partner_bank(osv.osv): res += super(res_partner_bank, self).name_get(cr, uid, to_check_ids, context) return res - def search(self, cr, uid, args, offset=0, limit=None, order=None, - context=None, count=False): - res = super(res_partner_bank,self).search(cr, uid, args, offset, limit, - order, context=context, count=count) + def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): + #overwrite the search method in order to search not only on bank type == basic account number but also on type == iban + res = super(res_partner_bank,self).search(cr, uid, args, offset, limit, order, context=context, count=count) if filter(lambda x:x[0]=='acc_number' ,args): + #get the value of the search iban_value = filter(lambda x:x[0]=='acc_number' ,args)[0][2] + #get the other arguments of the search args1 = filter(lambda x:x[0]!='acc_number' ,args) + #add the new criterion args1 += [('iban','ilike',iban_value)] + #append the results to the older search res += super(res_partner_bank,self).search(cr, uid, args1, offset, limit, order, context=context, count=count) return res + def get_bban_from_iban(self, cr, uid, ids, context=None): + ''' + This function returns the bank account number computed from the iban account number, thanks to the mapping_list dictionary that contains the rules associated to its country. + ''' + res = {} + mapping_list = { + #TODO add rules for others countries + 'be': lambda x: x[4:], + 'fr': lambda x: x[14:], + 'ch': lambda x: x[9:], + 'gb': lambda x: x[14:], + } + for record in self.browse(cr, uid, ids, context): + if not record.iban: + res[record.id] = False + continue + res[record.id] = False + for code, function in mapping_list.items(): + if record.iban.lower().startswith(code): + res[record.id] = function(record.iban) + break + return res + + _columns = { + 'iban': fields.char('IBAN', size=34, readonly=True, help="International Bank Account Number"), + } + + _constraints = [(check_iban, "The IBAN number doesn't seem to be correct.", ["iban"])] + res_partner_bank() diff --git a/addons/document/document.py b/addons/document/document.py index b28b81af7d9..d312b33f366 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -226,24 +226,27 @@ class document_directory(osv.osv): ('dirname_uniq', 'unique (name,parent_id,ressource_id,ressource_parent_type_id)', 'The directory name must be unique !') ] - def get_resource_path(self,cr,uid,res_model,res_id): - # to be need test + def get_resource_path(self,cr,uid,dir_id,res_model,res_id): + # this method will be used in process module + # to be need test and Improvement if resource dir has parent resource (link resource) path=[] - def _parent(dir_id): + def _parent(dir_id,path): parent=self.browse(cr,uid,dir_id) - if parent.parent_id: - _parent(parent.parent_id.id) - else: + if parent.parent_id and not parent.ressource_parent_type_id: + _parent(parent.parent_id.id,path) path.append(parent.name) - return path - model_ids=self.pool.get('ir.model').search(cr,uid,[('model','=',res_model)]) - directory_ids=self.search(cr,uid,[('ressource_type_id','=',model_ids[0]),('ressource_id','=',res_id)]) - if len(directory_ids): - path=parent(directory_ids[0]) - direc=self.browse(cr,uid,directory_ids)[0] - path.append(direc.name) - path.append(self.pool.get(direc.ressource_type_id.model).browse(cr,uid,res_id).name) - return "ftp://localhost:8021/"+cr.dbname+'/'.join(path) + else: + path.append(parent.name) + return path + + directory=self.browse(cr,uid,dir_id) + model_ids=self.pool.get('ir.model').search(cr,uid,[('model','=',res_model)]) + if directory: + _parent(dir_id,path) + path.append(self.pool.get(directory.ressource_type_id.model).browse(cr,uid,res_id).name) + user=self.pool.get('res.users').browse(cr,uid,uid) + #print "ftp://%s:%s@localhost:8021/%s/%s"%(user.login,user.password,cr.dbname,'/'.join(path)) + return "ftp://%s:%s@localhost:8021/%s/%s"%(user.login,user.password,cr.dbname,'/'.join(path)) return False def _check_duplication(self, cr, uid,vals): if 'name' in vals: @@ -343,8 +346,9 @@ class document_directory(osv.osv): return result def write(self, cr, uid, ids, vals, context=None): - if not self._check_duplication(cr,uid,vals): - raise except_orm('ValidateError', 'Directory name must be unique!') + # need to make constraints to checking duplicate + #if not self._check_duplication(cr,uid,vals): + # raise except_orm('ValidateError', 'Directory name must be unique!') return super(document_directory,self).write(cr,uid,ids,vals,context=context) def copy(self, cr, uid, id, default=None, context=None): diff --git a/addons/document/document_view.xml b/addons/document/document_view.xml index 1b44907af30..9567637605c 100644 --- a/addons/document/document_view.xml +++ b/addons/document/document_view.xml @@ -178,7 +178,7 @@ - + @@ -192,7 +192,7 @@ - + diff --git a/addons/event/event.py b/addons/event/event.py index adfe5b04386..2450441349a 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -134,8 +134,8 @@ class event(osv.osv): 'date_begin': fields.datetime('Beginning date', required=True), 'date_end': fields.datetime('Ending date', required=True), 'state': fields.selection([('draft','Draft'),('confirm','Confirmed'),('done','Done'),('cancel','Canceled')], 'Status', readonly=True, required=True), - 'mail_auto_registr':fields.boolean('Mail Auto Register',help='A mail is send when the registration is confirmed'), - 'mail_auto_confirm':fields.boolean('Mail Auto Confirm',help='A mail is send when the event is confimed'), + 'mail_auto_registr':fields.boolean('Mail Auto Register',help='A mail is sent when the registration is confirmed'), + 'mail_auto_confirm':fields.boolean('Mail Auto Confirm',help='A mail is sent when the event is confimed'), 'mail_registr':fields.text('Mail Register',help='Template for the mail'), 'mail_confirm':fields.text('Mail Confirm',help='Template for the mail'), 'budget_id':fields.many2one('account.budget.post','Budget'), @@ -163,13 +163,6 @@ class event_registration(osv.osv): obj.create(cr, uid, data, context) return True - def button_reg_open(self, cr, uid, ids, *args): - self.write(cr, uid, ids, {'state':'open',}) - cases = self.browse(cr, uid, ids) - self._history(cr, uid, cases, 'Open', history=True) - self.mail_user(cr,uid,ids) - return True - def button_reg_close(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state':'done',}) cases = self.browse(cr, uid, ids) @@ -223,7 +216,7 @@ class event_registration(osv.osv): "badge_name":fields.char('Badge Name',size=128), "badge_partner":fields.char('Badge Partner',size=128), "invoice_label":fields.char("Label Invoice",size=128,required=True), - "tobe_invoiced":fields.boolean("To be Invoice"), + "tobe_invoiced":fields.boolean("To be Invoiced"), "invoice_id":fields.many2one("account.invoice","Invoice"), } _defaults = { diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml index 081462b2675..f4f02d34b66 100644 --- a/addons/event/event_view.xml +++ b/addons/event/event_view.xml @@ -198,7 +198,7 @@
- + @@ -220,7 +220,7 @@