From 9762c519edb89367a26cc8d696566813cd3fa731 Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Mon, 15 Dec 2008 09:06:40 +0100 Subject: [PATCH 01/29] Fixed two "Invalid function definition" (mst use store={object:(fnct, fields, priority)} bzr revid: olt@tinyerp.com-20081215080640-d0dabqxwojx2kgx4 --- addons/membership/membership.py | 2 +- addons/mrp_operations/mrp_operations.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/membership/membership.py b/addons/membership/membership.py index 9752fcd7737..a1480201dc8 100644 --- a/addons/membership/membership.py +++ b/addons/membership/membership.py @@ -437,7 +437,7 @@ class Partner(osv.osv): # 'membership_state': fields.function(_membership_state, method=True, string='Current membership state', # type='selection', selection=STATE, fnct_search=_membership_state_search), 'membership_state': fields.function(_membership_state, method=True, string='Current membership state', - type='selection',selection=STATE,store={'account.invoice':(_membership_state_search_inv,['state'])}), + type='selection',selection=STATE,store={'account.invoice':(_membership_state_search_inv,['state'], 10)}), # 'associate_member': fields.many2one('res.partner', 'Associate member'), 'free_member': fields.boolean('Free member'), 'membership_start': fields.function(_membership_start, method=True, diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index 923a5a5d600..72316aca8bd 100755 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -294,7 +294,7 @@ class mrp_operations_operation(osv.osv): 'code_id':fields.many2one('mrp_operations.operation.code','Code',required=True), 'date_start': fields.datetime('Start Date'), 'date_finished': fields.datetime('End Date'), - 'order_date': fields.function(_get_order_date,method=True,string='Order Date',type='date',store={'mrp.production':(_order_date_search_production,['date_planned'])}), + 'order_date': fields.function(_get_order_date,method=True,string='Order Date',type='date',store={'mrp.production':(_order_date_search_production,['date_planned'], 10)}), } _defaults={ 'date_start': lambda *a:DateTime.now().strftime('%Y-%m-%d %H:%M:%S') From 367a131bed07bf368d7e7d8bec1c243aa70f1022 Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Mon, 15 Dec 2008 10:16:30 +0100 Subject: [PATCH 02/29] Fixed a bad identifier: 'inv' -> 'invoice' bzr revid: olt@tinyerp.com-20081215091630-ztcb3wxnpg9zz1xe --- addons/account/invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 7307a2fbd3b..b995014bd23 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -836,7 +836,7 @@ class account_invoice(osv.osv): } lines = [(0, 0, l1), (0, 0, l2)] - move = {'ref': inv.number, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} + move = {'ref': invoice.number, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} move_id = self.pool.get('account.move').create(cr, uid, move) line_ids = [] From cbce9e585d095bbd786d1937846c2ab01e134a76 Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Mon, 15 Dec 2008 11:41:24 +0100 Subject: [PATCH 03/29] bugfixes: * 'account.move': trying to create one without 'name' * 'account.move.line': trying to create one without 'currency_id' bzr revid: olt@tinyerp.com-20081215104124-ah9j16sqrvozi7cc --- addons/account/account_move_line.py | 5 +++++ addons/account/invoice.py | 4 ++++ addons/account/wizard/wizard_pay_invoice.py | 1 - 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index ffef364ae37..18c9930b244 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -850,6 +850,7 @@ class account_move_line(osv.osv): if journal.analytic_journal_id: vals['analytic_lines'] = [(0,0, { 'name': vals['name'], + 'currency_id': account.company_id.currency_id.id, 'date': vals.get('date', time.strftime('%Y-%m-%d')), 'account_id': vals['analytic_account_id'], 'unit_amount':'quantity' in vals and vals['quantity'] or 1.0, @@ -860,6 +861,10 @@ class account_move_line(osv.osv): })] else: raise osv.except_osv(_('No analytic journal !'), _('Please set an analytic journal on this financial journal !')) + + #if not 'currency_id' in vals: + # vals['currency_id'] = account.company_id.currency_id.id + result = super(osv.osv, self).create(cr, uid, vals, context) # CREATE Taxes if 'account_tax_id' in vals and vals['account_tax_id']: diff --git a/addons/account/invoice.py b/addons/account/invoice.py index b995014bd23..8f33c013bd0 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -616,6 +616,10 @@ class account_invoice(osv.osv): move['period_id'] = period_id for i in line: i[2]['period_id'] = period_id + + if not 'name' in move: + move['name'] = inv.name + move_id = self.pool.get('account.move').create(cr, uid, move) new_move_name = self.pool.get('account.move').browse(cr, uid, move_id).name # make the invoice point to that move diff --git a/addons/account/wizard/wizard_pay_invoice.py b/addons/account/wizard/wizard_pay_invoice.py index bec4a3c164f..417de8e5212 100644 --- a/addons/account/wizard/wizard_pay_invoice.py +++ b/addons/account/wizard/wizard_pay_invoice.py @@ -60,7 +60,6 @@ def _pay_and_reconcile(self, cr, uid, data, context): ctx = {'date':data['form']['date']} amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx) - # Take the choosen date if form.has_key('comment'): context={'date_p':form['date'],'comment':form['comment']} From 5ef9a695262841f04002c0f8d8de0710d1ff61b5 Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Mon, 15 Dec 2008 16:17:29 +0530 Subject: [PATCH 04/29] modify hr_expense report-vir bzr revid: patelamit2003@gmail.com-20081215104729-r3ssnb7yvp8zrmsv --- addons/hr_expense/report/expense.rml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/addons/hr_expense/report/expense.rml b/addons/hr_expense/report/expense.rml index 7c1ecd03635..fe6714ab8cb 100644 --- a/addons/hr_expense/report/expense.rml +++ b/addons/hr_expense/report/expense.rml @@ -213,40 +213,33 @@ - - [[ format(line.analytic_account and line.analytic_account.complete_name or removeParentNode('tr')) ]] + [[ line.analytic_account and line.analytic_account.complete_name or removeParentNode('tr') ]] - - - - - - @@ -297,4 +290,4 @@ This document must be dated and signed for reimbursment - + \ No newline at end of file From f0f0b55df3f3e9a7acb8fa5727a5c5e0bc3afefc Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 15 Dec 2008 11:56:18 +0100 Subject: [PATCH 05/29] [FIX] unicode problems lp bug: https://launchpad.net/bugs/307908 fixed bzr revid: christophe@cobalt-20081215105618-c9ifz3x4pepvwkeb --- addons/crm_profiling/crm_profiling.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/crm_profiling/crm_profiling.py b/addons/crm_profiling/crm_profiling.py index c5a8b118b0f..708294490f5 100644 --- a/addons/crm_profiling/crm_profiling.py +++ b/addons/crm_profiling/crm_profiling.py @@ -137,11 +137,11 @@ class questionnaire(osv.osv): quest_fields={} quest_form='''
''' % _('Questionnaire') - for x in result: - quest_form = quest_form + '''''' - quest_fields['quest_form'+str(x[1])] = {'string': str(x[0]), 'type': 'many2one', 'relation': 'crm_profiling.answer', 'domain': [('question_id','=',x[1])] } + for name, oid in result: + quest_form = quest_form + '' % (oid,) + quest_fields['quest_form%d' % (oid,)] = {'string': name, 'type': 'many2one', 'relation': 'crm_profiling.answer', 'domain': [('question_id','=',oid)] } quest_form = quest_form + '''''' - return quest_form,quest_fields + return quest_form, quest_fields _columns = { 'name': fields.char("Questionnaire",size=128, required=True), From 077e97c5d8b621183b0f15b76fab48fcf4f717ea Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Mon, 15 Dec 2008 12:41:34 +0100 Subject: [PATCH 06/29] Bugfix: 'account.move.line': trying to create one without 'name' bzr revid: olt@tinyerp.com-20081215114134-anj9f1yu70n8yg2i --- addons/account/invoice.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 8f33c013bd0..b1694169646 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -839,6 +839,10 @@ class account_invoice(osv.osv): 'ref':invoice.number, } + name = invoice.invoice_line[0].name + l1['name'] = name + l2['name'] = name + lines = [(0, 0, l1), (0, 0, l2)] move = {'ref': invoice.number, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} move_id = self.pool.get('account.move').create(cr, uid, move) From 4297d5a743766328d9de02df8a6b20c6508bf7f7 Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Mon, 15 Dec 2008 12:46:57 +0100 Subject: [PATCH 07/29] wrong identifier: frags -> fargs bzr revid: olt@tinyerp.com-20081215114657-7do9gloamn3esv9y --- addons/account/account_move_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 18c9930b244..ef63c5e6890 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -273,7 +273,7 @@ class account_move_line(osv.osv): while i < len(args): fargs = args[i][0].split('.', 1) if len(fargs) > 1: - args[i] = (frags[0], 'in', invoice_obj.search(cursor, user, + args[i] = (fargs[0], 'in', invoice_obj.search(cursor, user, [(fargs[1], args[i][1], args[i][2])])) i += 1 continue From 05c0ca772168dfc9ba33273dc00cc34a540dd21f Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Mon, 15 Dec 2008 17:18:52 +0530 Subject: [PATCH 08/29] fix the problem of analytic account with the voucher entry improve the voucher entry system lp bug: https://launchpad.net/bugs/296760 fixed bzr revid: mga@tinyerp.com-20081215114852-j5gij01eby4p0gqg --- .../account_voucher_sequence.xml | 56 ++---- addons/account_voucher/voucher.py | 176 ++++++++++++------ addons/account_voucher/voucher_view.xml | 2 +- 3 files changed, 135 insertions(+), 99 deletions(-) diff --git a/addons/account_voucher/account_voucher_sequence.xml b/addons/account_voucher/account_voucher_sequence.xml index 70e804de8c6..b8935e76182 100644 --- a/addons/account_voucher/account_voucher_sequence.xml +++ b/addons/account_voucher/account_voucher_sequence.xml @@ -1,7 +1,7 @@ - + Voucher account.voucher @@ -12,32 +12,32 @@ --> Account Cash Received Voucher - account.voucher.rec_voucher + rec_voucher Account Cash Payble Voucher - account.voucher.pay_voucher + pay_voucher Account Bank Received Voucher - account.voucher.bank_rec_voucher + bank_rec_voucher Account Bank Payble Voucher - account.voucher.bank_pay_voucher + bank_pay_voucher Account Contra Voucher - account.voucher.cont_voucher + cont_voucher - Account Journal Voucher - account.voucher.journal_sale_vou + Sales Journal Voucher + journal_sale_voucher - Account Journal Voucher - account.voucher.journal_pur_vou + Purchase Journal Voucher + journal_pur_voucher Account Cash Received Voucher - account.voucher.rec_voucher + rec_voucher %(year)s/ Account Cash Payble Voucher - account.voucher.pay_voucher + pay_voucher %(year)s/ Account Bank Received Voucher - account.voucher.bank_rec_voucher + bank_rec_voucher %(year)s/ Account Bank Payble Voucher - account.voucher.bank_pay_voucher + bank_pay_voucher %(year)s/ Account Contra Voucher - account.voucher.cont_voucher + cont_voucher %(year)s/ - Account Journal Voucher - account.voucher.journal_sale_vou + Sales Journal Voucher + journal_sale_voucher %(year)s/ - Account Journal Voucher - account.voucher.journal_pur_vou + Purchase Journal Voucher + journal_pur_voucher %(year)s/ - diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index c8f3660cd7e..611edebfc92 100755 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -82,7 +82,7 @@ class account_voucher(osv.osv): ('rec_voucher','Cash Receipt Voucher'), ('bank_rec_voucher','Bank Receipt Voucher'), ('cont_voucher','Contra Voucher'), - ('journal_sale_vou','Journal Sale Voucher'), + ('journal_sale_voucher','Journal Sale Voucher'), ('journal_pur_voucher','Journal Purchase Voucher'), ],'Type', readonly=True, select=True), 'date':fields.date('Date', readonly=True, states={'draft':[('readonly',False)]}), @@ -99,7 +99,7 @@ class account_voucher(osv.osv): ('posted','Posted'), ('cancel','Cancel') ], 'State', - readonly=True), + readonly=True, size=32), 'amount':fields.float('Amount'), 'number':fields.char('Number', size=32, readonly=True), 'reference': fields.char('Voucher Reference', size=64), @@ -110,7 +110,6 @@ class account_voucher(osv.osv): } _defaults = { - #'journal_id':get_bank, 'state': lambda *a: 'draft', 'date' : lambda *a: time.strftime('%Y-%m-%d'), 'period_id': _get_period, @@ -142,16 +141,13 @@ class account_voucher(osv.osv): if journal_id and (type in ('rec_voucher','bank_rec_voucher','journal_pur_voucher')): account_id = journal.browse(cr, uid, journal_id).default_debit_account_id return {'value':{'account_id':account_id.id}} - elif journal_id and (type in ('pay_voucher','bank_pay_voucher','journal_sale_vou')) : + elif journal_id and (type in ('pay_voucher','bank_pay_voucher','journal_sale_voucher')) : account_id = journal.browse(cr, uid, journal_id).default_credit_account_id return {'value':{'account_id':account_id.id}} else: account_id = journal.browse(cr, uid, journal_id).default_credit_account_id return {'value':{'account_id':account_id.id}} - - - - + def open_voucher(self, cr, uid, ids, context={}): obj=self.pool.get('account.voucher').browse(cr,uid,ids) total=0 @@ -203,16 +199,16 @@ class account_voucher(osv.osv): for il in iml: if il['account_analytic_id']: - if inv.type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_vou','journal_pur_voucher'): + if inv.type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_voucher','journal_pur_voucher'): ref = inv.reference else: ref = self._convert_ref(cr, uid, inv.number) - il['analytic_lines'] = [(0,0, { + + il['analytic_lines'] = [(0, 0, { 'name': il['name'], 'date': inv['date'], 'account_id': il['account_analytic_id'], 'amount': inv['amount'] * sign, - #'partner_id': il['partner_id'] or False, 'general_account_id': il['account_id'] or False, 'journal_id': self.pool.get('account.voucher').browse(cr, uid, id).journal_id.analytic_journal_id.id or False, 'ref': ref, @@ -222,43 +218,41 @@ class account_voucher(osv.osv): def action_move_line_create(self, cr, uid, ids, *args): for inv in self.browse(cr, uid, ids): - if inv.move_id: continue - company_currency = inv.company_id.currency_id.id - - # create the analytical lines + line_ids = self.read(cr, uid, [inv.id], ['payment_ids'])[0]['payment_ids'] ils = self.pool.get('account.voucher.line').read(cr, uid, line_ids) - # one move line per invoice line + iml = self._get_analytic_lines(cr, uid, inv.id) - # check if taxes are all computed + diff_currency_p = inv.currency_id.id <> company_currency - # create one move line for the total and possibly adjust the other lines amount + total = 0 - if inv.type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_vou','journal_pur_voucher'): + if inv.type in ('pay_voucher', 'journal_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_voucher','journal_pur_voucher'): ref = inv.reference else: ref = self._convert_ref(cr, uid, inv.number) + date = inv.date total_currency = 0 for i in iml: + partner_id=i['partner_id'] + acc_id = i['account_id'] if inv.currency_id.id != company_currency: i['currency_id'] = inv.currency_id.id i['amount_currency'] = i['amount'] else: i['amount_currency'] = False i['currency_id'] = False - i['ref'] = ref - if inv.type in ('rec_voucher','bank_rec_voucher','journal_pur_voucher'): + if inv.type in ('rec_voucher','bank_rec_voucher','journal_pur_voucher','journal_voucher'): total += i['amount'] total_currency += i['amount_currency'] or i['amount'] i['amount'] = - i['amount'] else: total -= i['amount'] total_currency -= i['amount_currency'] or i['amount'] - acc_id = inv.account_id.id name = inv['name'] or '/' totlines = False @@ -266,39 +260,104 @@ class account_voucher(osv.osv): iml.append({ 'type': 'dest', 'name': name, - 'amount': total, + 'amount': total or False, 'account_id': acc_id, 'amount_currency': diff_currency_p \ and total_currency or False, 'currency_id': diff_currency_p \ and inv.currency_id.id or False, - 'ref': ref + 'ref': ref, + 'partner_id':partner_id or False, }) date = inv.date inv.amount=total - line = map(lambda x:(0, 0, self.line_get_convert(cr, uid, x,date, context={})), iml) - - journal_id = inv.journal_id.id #self._get_journal(cr, uid, {'type': inv['type']}) + line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x,date, context={})) ,iml) + an_journal_id=inv.journal_id.analytic_journal_id.id + journal_id = inv.journal_id.id + journal = self.pool.get('account.journal').browse(cr, uid, journal_id) if journal.sequence_id: name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id) - move = {'name': name, 'line_id': line, 'journal_id': journal_id} + move = {'name': name, 'journal_id': journal_id} if inv.period_id: move['period_id'] = inv.period_id.id for i in line: i[2]['period_id'] = inv.period_id.id move_id = self.pool.get('account.move').create(cr, uid, move) + ref=move['name'] + amount=0.0 + + #create the first line our self + move_line = { + 'name': inv.name, + 'debit': False, + 'credit':False, + 'account_id': inv.account_id.id or False, + 'move_id':move_id , + 'journal_id':journal_id , + 'period_id':inv.period_id.id, + 'partner_id': False, + 'ref': ref, + 'date': inv.date + } + if inv.type in ('rec_voucher', 'bank_rec_voucher', 'journal_pur_voucher', 'journal_voucher'): + move_line['debit'] = inv.amount + else: + move_line['credit'] = inv.amount * (-1) + self.pool.get('account.move.line').create(cr, uid, move_line) + + for line in inv.payment_ids: + + move_line = { + 'name':line.name, + 'debit':False, + 'credit':False, + 'account_id':line.account_id.id or False, + 'move_id':move_id , + 'journal_id':journal_id , + 'period_id':inv.period_id.id, + 'partner_id':line.partner_id.id or False, + 'ref':ref, + 'date':inv.date + } + + if line.type == 'dr': + move_line['debit'] = line.amount or False + amount=line.amount + elif line.type == 'cr': + move_line['credit'] = line.amount or False + amount=line.amount * (-1) + ml_id=self.pool.get('account.move.line').create(cr, uid, move_line) + + if inv.narration: + line.name=inv.narration + else: + line.name=line.name + + an_line = { + 'name':line.name, + 'date':inv.date, + 'amount':amount, + 'account_id':line.account_analytic_id.id or False, + 'move_id':ml_id, + 'journal_id':an_journal_id , + 'general_account_id':line.account_id.id, + 'ref':ref + } + self.pool.get('account.analytic.line').create(cr,uid,an_line) + self.write(cr, uid, [inv.id], {'move_id': move_id}) - obj=self.pool.get('account.move').browse(cr,uid,move_id) + obj=self.pool.get('account.move').browse(cr, uid, move_id) + for line in obj.line_id : - cr.execute('insert into voucher_id (account_id,rel_account_move) values (%s, %s)',(int(ids[0]),int(line.id))) - + cr.execute('insert into voucher_id (account_id,rel_account_move) values (%d, %d)',(int(ids[0]),int(line.id))) + return True - + def line_get_convert(self, cr, uid, x, date, context={}): return { 'date':date, @@ -326,9 +385,9 @@ class account_voucher(osv.osv): for (id, invtype, number, move_id, reference) in cr.fetchall(): if not number: number = self.pool.get('ir.sequence').get(cr, uid, - 'account.voucher.' + invtype) + invtype) - if type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_vou','journal_pur_voucher'): + if type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_voucher','journal_pur_voucher'): ref = reference else: ref = self._convert_ref(cr, uid, number) @@ -344,21 +403,18 @@ class account_voucher(osv.osv): (ref, move_id)) return True - - def name_get(self, cr, uid, ids, context={}): if not len(ids): return [] types = { - 'pay_voucher': 'CPV: ', - 'rec_voucher': 'CRV: ', - 'cont_voucher': 'CV: ', - 'bank_pay_voucher': 'BPV: ', - 'bank_rec_voucher': 'BRV: ', - 'journal_sale_vou': 'JSV: ', - 'journal_pur_voucher': 'JPV: ', - - } + 'pay_voucher': 'CPV: ', + 'rec_voucher': 'CRV: ', + 'cont_voucher': 'CV: ', + 'bank_pay_voucher': 'BPV: ', + 'bank_rec_voucher': 'BRV: ', + 'journal_sale_voucher': 'JSV: ', + 'journal_pur_voucher': 'JPV: ', + } return [(r['id'], types[r['type']]+(r['number'] or '')+' '+(r['name'] or '')) for r in self.read(cr, uid, ids, ['type', 'number', 'name'], context, load='_classic_write')] def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): @@ -426,12 +482,11 @@ class VoucherLine(osv.osv): res.append(self.move_line_get_item(cr, uid, line, context)) return res - def onchange_partner(self, cr, uid, ids, partner_id, type,type1): + def onchange_partner(self, cr, uid, ids, partner_id, type, type1): if not partner_id: return {'value' : {'account_id' : False, 'type' : False ,'amount':False}} obj = self.pool.get('res.partner') account_id = False - if type1 in ('rec_voucher','bank_rec_voucher'): account_id = obj.browse(cr, uid, partner_id).property_account_receivable balance=obj.browse(cr,uid,partner_id).credit @@ -440,12 +495,11 @@ class VoucherLine(osv.osv): account_id = obj.browse(cr, uid, partner_id).property_account_payable balance=obj.browse(cr,uid,partner_id).debit type = 'dr' - elif type1 in ('journal_sale_vou') : + elif type1 in ('journal_sale_voucher') : account_id = obj.browse(cr, uid, partner_id).property_account_receivable balance=obj.browse(cr,uid,partner_id).credit type = 'dr' - - elif type1 in ('journal_pur_vou') : + elif type1 in ('journal_pur_voucher') : account_id = obj.browse(cr, uid, partner_id).property_account_payable balance=obj.browse(cr,uid,partner_id).debit type = 'cr' @@ -474,7 +528,7 @@ class VoucherLine(osv.osv): account_id = obj.browse(cr, uid, partner_id).property_account_payable type = 'dr' - elif type1 in ('journal_sale_vou') : + elif type1 in ('journal_sale_voucher') : if amount < 0 : account_id = obj.browse(cr, uid, partner_id).property_account_payable type = 'cr' @@ -482,7 +536,7 @@ class VoucherLine(osv.osv): account_id = obj.browse(cr, uid, partner_id).property_account_receivable type = 'dr' - elif type1 in ('journal_pur_vou') : + elif type1 in ('journal_pur_voucher') : if amount< 0 : account_id = obj.browse(cr, uid, partner_id).property_account_receivable type = 'dr' @@ -516,7 +570,7 @@ class VoucherLine(osv.osv): account_id = obj.browse(cr, uid, partner_id).property_account_payable amount*=1 - elif type1 in ('journal_sale_vou') : + elif type1 in ('journal_sale_voucher') : if type == 'cr' : account_id = obj.browse(cr, uid, partner_id).property_account_payable amount*=-1 @@ -524,7 +578,7 @@ class VoucherLine(osv.osv): account_id = obj.browse(cr, uid, partner_id).property_account_receivable amount*=1 - elif type1 in ('journal_pur_vou') : + elif type1 in ('journal_pur_voucher') : if type == 'dr' : account_id = obj.browse(cr, uid, partner_id).property_account_receivable amount*=-1 @@ -539,12 +593,12 @@ class VoucherLine(osv.osv): def move_line_get_item(self, cr, uid, line, context={}): return { - 'type':'src', - 'name': line.name[:64], - 'amount':line.amount, - 'account_id':line.account_id.id, - 'partner_id':line.partner_id.id or False , - 'account_analytic_id':line.account_analytic_id.id or False, - } + 'type':'src', + 'name': line.name[:64], + 'amount':line.amount, + 'account_id':line.account_id.id, + 'partner_id':line.partner_id.id or False , + 'account_analytic_id':line.account_analytic_id.id or False, + } VoucherLine() diff --git a/addons/account_voucher/voucher_view.xml b/addons/account_voucher/voucher_view.xml index 872d831fa79..7f5cf40cd32 100755 --- a/addons/account_voucher/voucher_view.xml +++ b/addons/account_voucher/voucher_view.xml @@ -35,7 +35,7 @@ - + From 86ece830538feff751d60ee477e20e26ac09b6b0 Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Mon, 15 Dec 2008 12:57:55 +0100 Subject: [PATCH 09/29] Bugfix: account.move without 'name' bzr revid: olt@tinyerp.com-20081215115755-v8qvzenx5sbml988 --- addons/account/invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index b1694169646..3987d190f16 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -618,7 +618,7 @@ class account_invoice(osv.osv): i[2]['period_id'] = period_id if not 'name' in move: - move['name'] = inv.name + move['name'] = inv.name or '/' move_id = self.pool.get('account.move').create(cr, uid, move) new_move_name = self.pool.get('account.move').browse(cr, uid, move_id).name From aca4388202310eefda0deb386d4b4a840371a56c Mon Sep 17 00:00:00 2001 From: Jay Vora Date: Mon, 15 Dec 2008 17:34:01 +0530 Subject: [PATCH 10/29] Misc. changes bzr revid: jvo@tinyerp.com-20081215120401-g8x1llt6dtlfqnfj --- addons/account/account.py | 1 - addons/account/account_move_line.py | 1 - 2 files changed, 2 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index d80c77df52c..997fe2b3c59 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -832,7 +832,6 @@ class account_move(osv.osv): if 'line_id' in vals: c = context.copy() c['novalidate'] = True - print 'XXXXXXXXXXXXXXXXXXX : ',vals result = super(account_move, self).create(cr, uid, vals, c) self.validate(cr, uid, [result], context) else: diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index ef63c5e6890..be15a444ad7 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -728,7 +728,6 @@ class account_move_line(osv.osv): if vals.get('date', False): todo_date = vals['date'] del vals['date'] - print 'Writing', vals, 'to move_line', ids result = super(account_move_line, self).write(cr, uid, ids, vals, context) if check: From 55251a498e5f25f2a2fd00323993837d48a0fee2 Mon Sep 17 00:00:00 2001 From: Sofia Date: Mon, 15 Dec 2008 17:37:28 +0530 Subject: [PATCH 11/29] Tax array added while amount is zero [done by vir] bzr revid: sahibsofia@gmail.com-20081215120728-sbbwcclm6eyrx3tj --- addons/account/report/invoice.rml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/account/report/invoice.rml b/addons/account/report/invoice.rml index 6247ca00818..e1a65319898 100644 --- a/addons/account/report/invoice.rml +++ b/addons/account/report/invoice.rml @@ -327,7 +327,7 @@ [[ l.name ]] - [[ ', '.join([lt.name for lt in l.invoice_line_tax_id]) or '0.00' ]] + [[ ', '.join([lt.name for lt in l.invoice_line_tax_id]) or '' ]] [[ formatLang(l.quantity) or '0.00' ]] @@ -463,7 +463,7 @@ - [[ format(o.amount_tax or removeParentNode('blockTable')) ]] + @@ -491,10 +491,10 @@ [[ t.name ]] - [[ formatLang(t.base) ]] + [[ formatLang(t.base) or '0.00' ]] - [[ formatLang(t.amount) or 0.00 ]] + [[ formatLang(t.amount) or '0.00' ]] @@ -559,4 +559,4 @@ - + \ No newline at end of file From 90f334cfcf60d62d5192488cfa6d98aeabaada28 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Mon, 15 Dec 2008 17:39:18 +0530 Subject: [PATCH 12/29] fixing for the analytic account in voucher entry bzr revid: mga@tinyerp.com-20081215120918-737pk2agyia6534o --- addons/account_voucher/voucher.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index 611edebfc92..287bb2c8353 100755 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -331,6 +331,7 @@ class account_voucher(osv.osv): elif line.type == 'cr': move_line['credit'] = line.amount or False amount=line.amount * (-1) + ml_id=self.pool.get('account.move.line').create(cr, uid, move_line) if inv.narration: @@ -338,17 +339,18 @@ class account_voucher(osv.osv): else: line.name=line.name - an_line = { - 'name':line.name, - 'date':inv.date, - 'amount':amount, - 'account_id':line.account_analytic_id.id or False, - 'move_id':ml_id, - 'journal_id':an_journal_id , - 'general_account_id':line.account_id.id, - 'ref':ref - } - self.pool.get('account.analytic.line').create(cr,uid,an_line) + if line.account_analytic_id: + an_line = { + 'name':line.name, + 'date':inv.date, + 'amount':amount, + 'account_id':line.account_analytic_id.id or False, + 'move_id':ml_id, + 'journal_id':an_journal_id , + 'general_account_id':line.account_id.id, + 'ref':ref + } + self.pool.get('account.analytic.line').create(cr,uid,an_line) self.write(cr, uid, [inv.id], {'move_id': move_id}) obj=self.pool.get('account.move').browse(cr, uid, move_id) From 8f688adaa99e7f71c7eb1ad318d8d80399e52cbe Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Mon, 15 Dec 2008 13:15:02 +0100 Subject: [PATCH 13/29] .has_key() is deprecated, use 'in' bzr revid: olt@tinyerp.com-20081215121502-f1e6onelzbtwjzo6 --- addons/account/invoice.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 3987d190f16..fb25b7b8f02 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -497,7 +497,7 @@ class account_invoice(osv.osv): total_currency = 0 key_line=[] for i in iml: - if i.has_key('account_id') and i.has_key('taxes'): + if 'account_id' in i and 'taxes' in i: if not (i['account_id'],i['taxes']) in key_line: key_line.append((i['account_id'],i['taxes'])) if inv.currency_id.id != company_currency: @@ -528,7 +528,7 @@ class account_invoice(osv.osv): if acc_obj.browse(cr,uid,item[0]).merge_invoice: repeat=False for move_line in iml: - if (move_line.has_key('account_id') and move_line['account_id']==item[0]) and (move_line.has_key('taxes') and move_line['taxes']==item[1]): + if (move_line.has_key('account_id') and move_line['account_id']==item[0]) and ('taxes' in move_line and move_line['taxes']==item[1]): move_list.append(move_line) if repeat: for key in move_line: @@ -820,7 +820,7 @@ class account_invoice(osv.osv): types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} direction = types[invoice.type] #take the choosen date - if context.has_key('date_p') and context['date_p']: + if 'date_p' in context and context['date_p']: date=context['date_p'] else: date=time.strftime('%Y-%m-%d') From 2162b414fdd1cabc6e1f14f546cbd272cc2ea564 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 15 Dec 2008 17:47:02 +0530 Subject: [PATCH 14/29] audittrail bug fix bzr revid: mra@tinyerp.com-20081215121702-4lsck9r8yrtsetzz --- addons/audittrail/audittrail_view.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/audittrail/audittrail_view.xml b/addons/audittrail/audittrail_view.xml index ed7ff7294b2..654d060966b 100644 --- a/addons/audittrail/audittrail_view.xml +++ b/addons/audittrail/audittrail_view.xml @@ -76,14 +76,14 @@ - - + + - - + + From a9ddac89a6b4c71bd23c7a285e127de59272d27b Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Mon, 15 Dec 2008 13:41:13 +0100 Subject: [PATCH 15/29] Fixed: bad sql query if no inventory location was chosen when trying to set stock to 0. Now a warning dialog appear asking to choose at least one inventory location bzr revid: olt@tinyerp.com-20081215124113-v4omh9enhed60ek4 --- addons/stock/wizard/inventory_merge_zero.py | 32 ++++++++++++--------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/addons/stock/wizard/inventory_merge_zero.py b/addons/stock/wizard/inventory_merge_zero.py index f0ce60b4c22..19648d25dde 100644 --- a/addons/stock/wizard/inventory_merge_zero.py +++ b/addons/stock/wizard/inventory_merge_zero.py @@ -40,7 +40,7 @@ def do_merge(self, cr, uid, data, context): if len(data['ids']) <> 1: raise wizard.except_wizard("Warning", - "Please select one and only one inventory!") + "Please select one and only one inventory !") cr.execute('select distinct location_id from stock_inventory_line where inventory_id=%s', (data['ids'][0],)) loc_ids = map(lambda x: x[0], cr.fetchall()) @@ -49,19 +49,23 @@ def do_merge(self, cr, uid, data, context): cr.execute('select distinct location_id,product_id from stock_inventory_line where inventory_id=%s', (data['ids'][0],)) inv = cr.fetchall() - cr.execute('select distinct product_id from stock_move where (location_dest_id in ('+locs+')) or (location_id in ('+locs+'))') - stock = cr.fetchall() - for s in stock: - for loc in loc_ids: - if (loc,s[0]) not in inv: - p = prod_obj.browse(cr, uid, s[0]) - invent_line_obj.create(cr, uid, { - 'inventory_id': data['ids'][0], - 'location_id': loc, - 'product_id': s[0], - 'product_uom': p.uom_id.id, - 'product_qty': 0.0, - }) + if not inv: + raise wizard.except_wizard("Warning", + "Please select at least one inventory location !") + else: + cr.execute('select distinct product_id from stock_move where (location_dest_id in ('+locs+')) or (location_id in ('+locs+'))') + stock = cr.fetchall() + for s in stock: + for loc in loc_ids: + if (loc,s[0]) not in inv: + p = prod_obj.browse(cr, uid, s[0]) + invent_line_obj.create(cr, uid, { + 'inventory_id': data['ids'][0], + 'location_id': loc, + 'product_id': s[0], + 'product_uom': p.uom_id.id, + 'product_qty': 0.0, + }) return {} From 6af4fbbbed7122479be3045eb3d28d580277818d Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 15 Dec 2008 14:34:16 +0100 Subject: [PATCH 16/29] [FIX] close the db cursor bzr revid: christophe@cobalt-20081215133416-2biod95w2y4qs1hl --- addons/document/ftpserver/abstracted_fs.py | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/addons/document/ftpserver/abstracted_fs.py b/addons/document/ftpserver/abstracted_fs.py index c0f0bdf3407..c83fbb61d05 100644 --- a/addons/document/ftpserver/abstracted_fs.py +++ b/addons/document/ftpserver/abstracted_fs.py @@ -26,14 +26,16 @@ class file_wrapper(StringIO.StringIO): def close(self, *args, **kwargs): db,pool = pooler.get_db_and_pool(self.dbname) cr = db.cursor() - uid =self.uid - val = self.getvalue() - val2 = { - 'datas': base64.encodestring(val), - 'file_size': len(val), - } - pool.get('ir.attachment').write(cr, uid, [self.ressource_id], val2) - cr.commit() + try: + val = self.getvalue() + val2 = { + 'datas': base64.encodestring(val), + 'file_size': len(val), + } + pool.get('ir.attachment').write(cr, self.uid, [self.ressource_id], val2) + finally: + cr.commit() + cr.close() StringIO.StringIO.close(self, *args, **kwargs) class content_wrapper(StringIO.StringIO): @@ -47,10 +49,12 @@ class content_wrapper(StringIO.StringIO): def close(self, *args, **kwargs): db,pool = pooler.get_db_and_pool(self.dbname) cr = db.cursor() - getattr(self.pool.get('document.directory.content'), 'process_write_'+self.node.content.extension[1:])(cr, self.uid, self.node, self.getvalue()) + try: + getattr(self.pool.get('document.directory.content'), 'process_write_'+self.node.content.extension[1:])(cr, self.uid, self.node, self.getvalue()) + finally: + cr.commit() + cr.close() StringIO.StringIO.close(self, *args, **kwargs) - cr.commit() - cr.close() class abstracted_fs: From 929e87aaef0e9005fa336830d6f7ff41aef25487 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 15 Dec 2008 14:36:27 +0100 Subject: [PATCH 17/29] [FIX] base_module_publish: convert module name to string [IMP] base_module_publish: password is hidden bzr revid: christophe@cobalt-20081215133627-1sj43xbav1ehv47b --- .../wizard/base_module_publish.py | 14 +++++++------- addons/base_module_publish/wizard/module_zip.py | 13 +++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/addons/base_module_publish/wizard/base_module_publish.py b/addons/base_module_publish/wizard/base_module_publish.py index 74addefd82c..bfbba7676ad 100644 --- a/addons/base_module_publish/wizard/base_module_publish.py +++ b/addons/base_module_publish/wizard/base_module_publish.py @@ -129,7 +129,7 @@ upload_info_form = ''' align="0.0" colspan="4"/> - + ''' @@ -227,18 +227,18 @@ def _upload(self, cr, uid, datas, context): download = 'http://www.openerp.com/download/modules/'+res['module_filename'] result = post_multipart('www.openerp.com', '/mtree_upload.php', [ - ('login',datas['form']['login']), - ('password',datas['form']['password']), - ('module_name',mod.name) + ('login', datas['form']['login']), + ('password', datas['form']['password']), + ('module_name', str(mod.name)) ], [ ('module', res['module_filename'], res['module_file']) ]) - if result[0] == "1": + if result and result[0] == "1": raise wizard.except_wizard(_('Error'), _('Login failed!')) - elif result[0] == "2": + elif result and result[0] == "2": raise wizard.except_wizard(_('Error'), _('This version of the module is already exist on the server')) - elif result[0] != "0": + elif result and result[0] != "0": raise wizard.except_wizard(_('Error'), _('Failed to upload the file')) updata = { diff --git a/addons/base_module_publish/wizard/module_zip.py b/addons/base_module_publish/wizard/module_zip.py index 4014927bf99..c582358df0a 100644 --- a/addons/base_module_publish/wizard/module_zip.py +++ b/addons/base_module_publish/wizard/module_zip.py @@ -56,21 +56,22 @@ def createzip(cr, uid, moduleid, context, b64enc=True, src=True): _('Can not export module that is not installed!')) ad = tools.config['addons_path'] - if os.path.isdir(os.path.join(ad, module.name)): + name = str(module.name) + if os.path.isdir(os.path.join(ad, name)): archname = StringIO.StringIO('wb') archive = PyZipFile(archname, "w", ZIP_DEFLATED) - archive.writepy(os.path.join(ad, module.name)) - _zippy(archive, ad, module.name, src=src) + archive.writepy(os.path.join(ad, name)) + _zippy(archive, ad, name, src=src) archive.close() val =archname.getvalue() archname.close() - elif os.path.isfile(os.path.join(ad, module.name + '.zip')): - val = file(os.path.join(ad, module.name + '.zip'), 'rb').read() + elif os.path.isfile(os.path.join(ad, name + '.zip')): + val = file(os.path.join(ad, name + '.zip'), 'rb').read() else: raise wizard.except_wizard(_('Error'), _('Could not find the module to export!')) if b64enc: val =base64.encodestring(val) - return {'module_file':val, 'module_filename': module.name + '-' + \ + return {'module_file':val, 'module_filename': name + '-' + \ (module.installed_version or '0') + '.zip'} From ad5c7e4c65b19a2930582dd84c9575338d386e7a Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Mon, 15 Dec 2008 15:14:29 +0100 Subject: [PATCH 18/29] tab2space bzr revid: olt@tinyerp.com-20081215141429-tlqzrd0m35uq9vyd --- addons/account/report/account_balance.py | 6 +- addons/account/report/rml_parse.py | 283 +++++++++++------------ 2 files changed, 144 insertions(+), 145 deletions(-) mode change 100755 => 100644 addons/account/report/rml_parse.py diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index 85596741a3c..fc178ea3ea4 100755 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -28,7 +28,6 @@ import datetime from report import report_sxw class account_balance(report_sxw.rml_parse): - _name = 'report.account.account.balance' def __init__(self, cr, uid, name, context): super(account_balance, self).__init__(cr, uid, name, context) @@ -181,11 +180,12 @@ class account_balance(report_sxw.rml_parse): lst_string = '' lst_string = '\'' + '\',\''.join(map(str,acc_id)) + '\'' self.cr.execute("select code,id from account_account where id IN (%s)"%(lst_string)) - a_id = self.cr.fetchall() + a_id = self.cr.fetchall() a_id.sort() ids2 = [x[1] for x in a_id] - + result_acc += self.lines(form, ids2, done, level+1) + return result_acc def date_range(self,start,end): diff --git a/addons/account/report/rml_parse.py b/addons/account/report/rml_parse.py old mode 100755 new mode 100644 index cfb5646e555..7f442485314 --- a/addons/account/report/rml_parse.py +++ b/addons/account/report/rml_parse.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -31,148 +31,147 @@ import sys class rml_parse(report_sxw.rml_parse): - - def __init__(self, cr, uid, name, context): - super(rml_parse, self).__init__(cr, uid, name, context=None) - self.localcontext.update({ - 'comma_me': self.comma_me, - 'format_date': self._get_and_change_date_format_for_swiss, - 'strip_name' : self._strip_name, - 'explode_name' : self._explode_name, - }) + def __init__(self, cr, uid, name, context): + super(rml_parse, self).__init__(cr, uid, name, context=None) + self.localcontext.update({ + 'comma_me': self.comma_me, + 'format_date': self._get_and_change_date_format_for_swiss, + 'strip_name' : self._strip_name, + 'explode_name' : self._explode_name, + }) - def comma_me(self,amount): - #print "#" + str(amount) + "#" - if not amount: - amount = 0.0 - if type(amount) is float : - amount = str('%.2f'%amount) - else : - amount = str(amount) - if (amount == '0'): - return ' ' - orig = amount - new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount) - if orig == new: - return new - else: - return self.comma_me(new) - def _ellipsis(self, string, maxlen=100, ellipsis = '...'): - ellipsis = ellipsis or '' - try: - return string[:maxlen - len(ellipsis) ] + (ellipsis, '')[len(string) < maxlen] - except Exception, e: - return False - def _strip_name(self, name, maxlen=50): - return self._ellipsis(name, maxlen, '...') - - def _get_and_change_date_format_for_swiss (self,date_to_format): - date_formatted='' - if date_to_format: - date_formatted = strptime (date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y') - return date_formatted - - def _explode_name(self,chaine,length): - # We will test if the size is less then account - full_string = '' - if (len(str(chaine)) <= length): - return chaine - # - else: - chaine = unicode(chaine,'utf8').encode('iso-8859-1') - rup = 0 - for carac in chaine: - rup = rup + 1 - if rup == length: - full_string = full_string + '\n' - full_string = full_string + carac - rup = 0 - else: - full_string = full_string + carac - - return full_string - - def makeAscii(self,str): - try: - Stringer = str.encode("utf-8") - except UnicodeDecodeError: - try: - Stringer = str.encode("utf-16") - except UnicodeDecodeError: - print "UTF_16 Error" - Stringer = str - else: - return Stringer - else: - return Stringer - return Stringer - def explode_this(self,chaine,length): - #chaine = self.repair_string(chaine) - chaine = rstrip(chaine) - ast = list(chaine) - i = length - while i <= len(ast): - ast.insert(i,'\n') - i = i + length - chaine = str("".join(ast)) - return chaine - def repair_string(self,chaine): - ast = list(chaine) - UnicodeAst = [] - _previouslyfound = False - i = 0 - #print str(ast) - while i < len(ast): - elem = ast[i] - try: - Stringer = elem.encode("utf-8") - except UnicodeDecodeError: - to_reencode = elem + ast[i+1] - print str(to_reencode) - Good_char = to_reencode.decode('utf-8') - UnicodeAst.append(Good_char) - i += i +2 - else: - UnicodeAst.append(elem) - i += i + 1 - - - return "".join(UnicodeAst) - - def ReencodeAscii(self,str): - print sys.stdin.encoding - try: - Stringer = str.decode("ascii") - except UnicodeEncodeError: - print "REENCODING ERROR" - return str.encode("ascii") - except UnicodeDecodeError: - print "DECODING ERROR" - return str.encode("ascii") - - else: - print Stringer - return Stringer + def comma_me(self,amount): + #print "#" + str(amount) + "#" + if not amount: + amount = 0.0 + if type(amount) is float : + amount = str('%.2f'%amount) + else : + amount = str(amount) + if (amount == '0'): + return ' ' + orig = amount + new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount) + if orig == new: + return new + else: + return self.comma_me(new) + def _ellipsis(self, string, maxlen=100, ellipsis = '...'): + ellipsis = ellipsis or '' + try: + return string[:maxlen - len(ellipsis) ] + (ellipsis, '')[len(string) < maxlen] + except Exception, e: + return False + def _strip_name(self, name, maxlen=50): + return self._ellipsis(name, maxlen, '...') + + def _get_and_change_date_format_for_swiss (self,date_to_format): + date_formatted='' + if date_to_format: + date_formatted = strptime (date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y') + return date_formatted + + def _explode_name(self,chaine,length): + # We will test if the size is less then account + full_string = '' + if (len(str(chaine)) <= length): + return chaine + # + else: + chaine = unicode(chaine,'utf8').encode('iso-8859-1') + rup = 0 + for carac in chaine: + rup = rup + 1 + if rup == length: + full_string = full_string + '\n' + full_string = full_string + carac + rup = 0 + else: + full_string = full_string + carac + + return full_string + + def makeAscii(self,str): + try: + Stringer = str.encode("utf-8") + except UnicodeDecodeError: + try: + Stringer = str.encode("utf-16") + except UnicodeDecodeError: + print "UTF_16 Error" + Stringer = str + else: + return Stringer + else: + return Stringer + return Stringer + def explode_this(self,chaine,length): + #chaine = self.repair_string(chaine) + chaine = rstrip(chaine) + ast = list(chaine) + i = length + while i <= len(ast): + ast.insert(i,'\n') + i = i + length + chaine = str("".join(ast)) + return chaine + def repair_string(self,chaine): + ast = list(chaine) + UnicodeAst = [] + _previouslyfound = False + i = 0 + #print str(ast) + while i < len(ast): + elem = ast[i] + try: + Stringer = elem.encode("utf-8") + except UnicodeDecodeError: + to_reencode = elem + ast[i+1] + print str(to_reencode) + Good_char = to_reencode.decode('utf-8') + UnicodeAst.append(Good_char) + i += i +2 + else: + UnicodeAst.append(elem) + i += i + 1 + + + return "".join(UnicodeAst) + + def ReencodeAscii(self,str): + print sys.stdin.encoding + try: + Stringer = str.decode("ascii") + except UnicodeEncodeError: + print "REENCODING ERROR" + return str.encode("ascii") + except UnicodeDecodeError: + print "DECODING ERROR" + return str.encode("ascii") + + else: + print Stringer + return Stringer + + + # def _add_header(self, node): + # rml_head = tools.file_open('specific_param/report/header/corporate_rml_header_ch.rml').read() + # head_dom = xml.dom.minidom.parseString(rml_head) + # #for frame in head_dom.getElementsByTagName('frame'): + # # frame.parentNode.removeChild(frame) + # node2 = head_dom.documentElement + # for tag in node2.childNodes: + # if tag.nodeType==tag.ELEMENT_NODE: + # found = self._find_node(node, tag.localName) + # # rml_frames = found.getElementsByTagName('frame') + # if found: + # if tag.hasAttribute('position') and (tag.getAttribute('position')=='inside'): + # found.appendChild(tag) + # else: + # found.parentNode.replaceChild(tag, found) + # # for frame in rml_frames: + # # tag.appendChild(frame) + # return True - - # def _add_header(self, node): - # rml_head = tools.file_open('specific_param/report/header/corporate_rml_header_ch.rml').read() - # head_dom = xml.dom.minidom.parseString(rml_head) - # #for frame in head_dom.getElementsByTagName('frame'): - # # frame.parentNode.removeChild(frame) - # node2 = head_dom.documentElement - # for tag in node2.childNodes: - # if tag.nodeType==tag.ELEMENT_NODE: - # found = self._find_node(node, tag.localName) - # # rml_frames = found.getElementsByTagName('frame') - # if found: - # if tag.hasAttribute('position') and (tag.getAttribute('position')=='inside'): - # found.appendChild(tag) - # else: - # found.parentNode.replaceChild(tag, found) - # # for frame in rml_frames: - # # tag.appendChild(frame) - # return True - From f9156c66f7cca9a71ace212076f45b618eb599ea Mon Sep 17 00:00:00 2001 From: Najlaa Date: Mon, 15 Dec 2008 15:44:03 +0100 Subject: [PATCH 19/29] [FIX] Avoid crash when no ir_values bzr revid: nel@silver-20081215144403-3jtzlwxmaakramuk --- bin/addons/base/ir/ir_values.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/addons/base/ir/ir_values.py b/bin/addons/base/ir/ir_values.py index bd9a5ba2c69..9bffc4f0719 100644 --- a/bin/addons/base/ir/ir_values.py +++ b/bin/addons/base/ir/ir_values.py @@ -206,7 +206,8 @@ class ir_values(osv.osv): del fields[pos] else: pos+=1 - datas = self.pool.get(model).read(cr, uid, [id], fields, context)[0] + datas = self.pool.get(model).read(cr, uid, [id], fields, context) + datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) return False From 857315978abe63d87766c867d60eca8355141176 Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Mon, 15 Dec 2008 16:40:41 +0100 Subject: [PATCH 20/29] Fixed: 'intersect' method was not imported bzr revid: olt@tinyerp.com-20081215154041-09dnh954v64i6l9w --- addons/account_analytic_analysis/account_analytic_analysis.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index 9b18c2d3061..d08aba68947 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -21,6 +21,7 @@ ############################################################################## import operator from osv import osv, fields +from osv.orm import intersect from tools.translate import _ From 1106d052b6cfc6e49a9c0f12c3975be687d09111 Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Mon, 15 Dec 2008 16:51:27 +0100 Subject: [PATCH 21/29] Bugfix: 'obj_line' was not defined bzr revid: olt@tinyerp.com-20081215155127-bmygwbngxm2tmazf --- addons/account_analytic_plans/account_analytic_plans.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account_analytic_plans/account_analytic_plans.py b/addons/account_analytic_plans/account_analytic_plans.py index dc63e082a19..2bbfb9e82f0 100644 --- a/addons/account_analytic_plans/account_analytic_plans.py +++ b/addons/account_analytic_plans/account_analytic_plans.py @@ -286,7 +286,7 @@ class account_move_line(osv.osv): if line.analytics_id: toremove = self.pool.get('account.analytic.line').search(cr, uid, [('move_id','=',line.id)], context=context) if toremove: - obj_line.unlink(cr, uid, toremove, context=context) + line.unlink(cr, uid, toremove, context=context) for line2 in line.analytics_id.account_ids: val = (line.credit or 0.0) - (line.debit or 0.0) amt=val * (line2.rate/100) From 2311698c51b4ce3fbc91d1885125b22da02b01f9 Mon Sep 17 00:00:00 2001 From: Olivier Laurent Date: Mon, 15 Dec 2008 17:22:33 +0100 Subject: [PATCH 22/29] "Bugfix: 'properties' was not defined" bzr revid: olt@tinyerp.com-20081215162233-v9m4ceexzgr9eieg --- addons/mrp/mrp.py | 2 +- addons/mrp/wizard/wizard_change_production_qty.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 331af2aeb99..901f38beab4 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -235,7 +235,7 @@ class mrp_bom(osv.osv): return {'value': v} return {} - def _bom_find(self, cr, uid, product_id, product_uom, properties = []): + def _bom_find(self, cr, uid, product_id, product_uom, properties=[]): bom_result = False # Why searching on BoM without parent ? cr.execute('select id from mrp_bom where product_id=%s and bom_id is null order by sequence', (product_id,)) diff --git a/addons/mrp/wizard/wizard_change_production_qty.py b/addons/mrp/wizard/wizard_change_production_qty.py index 3a031d8f5ce..6fca02332d5 100644 --- a/addons/mrp/wizard/wizard_change_production_qty.py +++ b/addons/mrp/wizard/wizard_change_production_qty.py @@ -67,7 +67,7 @@ def _change_prod_qty(self, cr, uid, data, context): bom_point = prod.bom_id bom_id = prod.bom_id.id if not bom_point: - bom_id = pool.get('mrp.bom')._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id, properties) + bom_id = pool.get('mrp.bom')._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id) if not bom_id: raise osv.except_osv('Error', "Couldn't find bill of material for product") self.write(cr, uid, [prod.id], {'bom_id': bom_id}) From 88c097516a5e5af5acee4655a276e5bf122b4051 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 16 Dec 2008 11:58:58 +0100 Subject: [PATCH 23/29] [FIX] handle the case when xml are in unicode bzr revid: christophe@cobalt-20081216105858-q0q02gxjt95qbmus --- bin/addons/base/ir/ir_ui_view.py | 2 +- bin/osv/orm.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/bin/addons/base/ir/ir_ui_view.py b/bin/addons/base/ir/ir_ui_view.py index afe4990aefc..70c336a7003 100644 --- a/bin/addons/base/ir/ir_ui_view.py +++ b/bin/addons/base/ir/ir_ui_view.py @@ -28,7 +28,7 @@ import os def _check_xml(self, cr, uid, ids, context={}): for view in self.browse(cr, uid, ids, context): - eview = etree.fromstring(view.arch) + eview = etree.fromstring(view.arch.encode('utf8')) frng = tools.file_open(os.path.join('base','rng','view.rng')) relaxng = etree.RelaxNG(file=frng) if not relaxng.validate(eview): diff --git a/bin/osv/orm.py b/bin/osv/orm.py index a81a8011d52..9b3487d71df 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -918,6 +918,12 @@ class orm_template(object): def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False): if not context: context = {} + + def encode(s): + if isinstance(s, unicode): + return s.encode('utf8') + return s + def _inherit_apply(src, inherit): def _find(node, node2): if node2.nodeType == node2.ELEMENT_NODE and node2.localName == 'xpath': @@ -940,9 +946,11 @@ class orm_template(object): if res: return res return None + - doc_src = dom.minidom.parseString(src) - doc_dest = dom.minidom.parseString(inherit) + netsvc.Logger().notifyChannel('orm', netsvc.LOG_DEBUG, type(src)) + doc_src = dom.minidom.parseString(encode(src)) + doc_dest = dom.minidom.parseString(encode(inherit)) toparse = doc_dest.childNodes while len(toparse): node2 = toparse.pop(0) @@ -1057,7 +1065,7 @@ class orm_template(object): result['field_parent'] = False result['view_id'] = 0 - doc = dom.minidom.parseString(result['arch'].encode('utf-8')) + doc = dom.minidom.parseString(encode(result['arch'])) xarch, xfields = self.__view_look_dom_arch(cr, user, doc, context=context) result['arch'] = xarch result['fields'] = xfields From 63f6d4e24ede40f11b7af29d73d6a20cf17edd17 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 16 Dec 2008 12:16:36 +0100 Subject: [PATCH 24/29] [IMP] downgrade the logging level to ERROR when the server cannot connect to the database bzr revid: christophe@cobalt-20081216111636-ahigto4u7l2kueeo --- bin/sql_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/sql_db.py b/bin/sql_db.py index 3f4e23cc392..eef2a52e92b 100644 --- a/bin/sql_db.py +++ b/bin/sql_db.py @@ -215,7 +215,7 @@ class PoolManager(object): logger.notifyChannel('dbpool', netsvc.LOG_INFO, 'Connecting to %s' % (db_name,)) PoolManager._pools[db_name] = ConnectionPool(ThreadedConnectionPool(1, PoolManager.maxconn, PoolManager.dsn(db_name)), db_name) except Exception, e: - logger.notifyChannel('dbpool', netsvc.LOG_CRITICAL, 'Unable to connect to %s: %s' % (db_name, e.message)) + logger.notifyChannel('dbpool', netsvc.LOG_ERROR, 'Unable to connect to %s: %s' % (db_name, e.message)) raise return PoolManager._pools[db_name] get = staticmethod(get) From 48bf6ab1e826123e667ffcd93fc6d50ccc8630cb Mon Sep 17 00:00:00 2001 From: Najlaa Date: Tue, 16 Dec 2008 13:59:34 +0100 Subject: [PATCH 25/29] call function scan language for selection field bzr revid: nel@silver-20081216125934-nmsxq3cmawhgtl3k --- bin/addons/base/module/wizard/wizard_export_lang.py | 5 +---- bin/addons/base/module/wizard/wizard_module_lang_install.py | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/bin/addons/base/module/wizard/wizard_export_lang.py b/bin/addons/base/module/wizard/wizard_export_lang.py index 2e9751e55e5..046b9ccb4dc 100644 --- a/bin/addons/base/module/wizard/wizard_export_lang.py +++ b/bin/addons/base/module/wizard/wizard_export_lang.py @@ -26,7 +26,6 @@ import base64 import StringIO import csv import pooler - from osv import fields,osv @@ -51,7 +50,6 @@ class wizard_export_lang(osv.osv_memory): mods = map(lambda m: m.name, this.modules) or ['all'] mods.sort() buf=StringIO.StringIO() - tools.trans_export(this.lang, mods, buf, this.format, dbname=cr.dbname) if this.format == 'csv': this.advice = _("Save this document to a .CSV file and open it with your favourite spreadsheet software. The file encoding is UTF-8. You have to translate the latest column before reimporting it.") @@ -64,8 +62,7 @@ class wizard_export_lang(osv.osv_memory): this.advice = _('Save this document to a .tgz file. This archive containt UTF-8 %s files and may be uploaded to launchpad.') % (ext,) this.name = "%s.%s" % (this.lang or _('new'), this.format) - - out=base64.encodestring(buf.getvalue()) + out=base64.encodestring(buf.getvalue().encode('utf8')) buf.close() return self.write(cr, uid, ids, {'state':'get', 'data':out, 'advice':this.advice, 'name':this.name}, context=context) diff --git a/bin/addons/base/module/wizard/wizard_module_lang_install.py b/bin/addons/base/module/wizard/wizard_module_lang_install.py index a3c4d6bdb99..d904fdb2a42 100644 --- a/bin/addons/base/module/wizard/wizard_module_lang_install.py +++ b/bin/addons/base/module/wizard/wizard_module_lang_install.py @@ -54,11 +54,8 @@ class wizard_lang_install(wizard.interface): modobj.update_translations(cr, uid, mids, lang) return {} - def _get_language(sel, cr, uid, context): - return tools.scan_languages() - fields_form = { - 'lang': {'string':'Language', 'type':'selection', 'selection':_get_language, + 'lang': {'string':'Language', 'type':'selection', 'selection':tools.scan_languages(), }, } From 4d3b92861091a8eba72453bcf7a891eeadbfbdbe Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 16 Dec 2008 17:21:12 +0100 Subject: [PATCH 26/29] [FIX] translate help of fields in wizards [FIX] fix unicode errors when exporting translations files lp bug: https://launchpad.net/bugs/308563 fixed lp bug: https://launchpad.net/bugs/308644 fixed bzr revid: christophe@cobalt-20081216162112-75r2kaflg3af0xxb --- .../base/module/wizard/wizard_export_lang.py | 2 +- bin/tools/translate.py | 63 ++++++++++++------- bin/wizard/__init__.py | 11 +++- 3 files changed, 49 insertions(+), 27 deletions(-) diff --git a/bin/addons/base/module/wizard/wizard_export_lang.py b/bin/addons/base/module/wizard/wizard_export_lang.py index 046b9ccb4dc..b7250762bcd 100644 --- a/bin/addons/base/module/wizard/wizard_export_lang.py +++ b/bin/addons/base/module/wizard/wizard_export_lang.py @@ -62,7 +62,7 @@ class wizard_export_lang(osv.osv_memory): this.advice = _('Save this document to a .tgz file. This archive containt UTF-8 %s files and may be uploaded to launchpad.') % (ext,) this.name = "%s.%s" % (this.lang or _('new'), this.format) - out=base64.encodestring(buf.getvalue().encode('utf8')) + out=base64.encodestring(buf.getvalue()) buf.close() return self.write(cr, uid, ids, {'state':'get', 'data':out, 'advice':this.advice, 'name':this.name}, context=context) diff --git a/bin/tools/translate.py b/bin/tools/translate.py index 7ed55f9fd94..00053a43d90 100644 --- a/bin/tools/translate.py +++ b/bin/tools/translate.py @@ -338,10 +338,17 @@ def trans_generate(lang, modules, dbname=None): tuple = (module, type, name, id, source) if source and tuple not in _to_translate: _to_translate.append(tuple) - + + def encode(s): + if isinstance(s, unicode): + return s.encode('utf8') + return s for (xml_name,model,res_id,module) in cr.fetchall(): - xml_name = module+'.'+xml_name + module = encode(module) + model = encode(model) + xml_name = "%s.%s" % (module, encode(xml_name)) + if not pool.get(model): logger.notifyChannel("db", netsvc.LOG_ERROR, "unable to find object %r" % (model,)) continue @@ -349,27 +356,32 @@ def trans_generate(lang, modules, dbname=None): if model=='ir.ui.view': d = xml.dom.minidom.parseString(obj.arch) for t in trans_parse_view(d.documentElement): - push_translation(module, 'view', obj.model, 0, t) + push_translation(module, 'view', encode(obj.model), 0, t) elif model=='ir.actions.wizard': - service_name = 'wizard.'+obj.wiz_name + service_name = 'wizard.'+encode(obj.wiz_name) obj2 = netsvc._service[service_name] for state_name, state_def in obj2.states.iteritems(): if 'result' in state_def: result = state_def['result'] if result['type'] != 'form': continue - name = obj.wiz_name + ',' + state_name + name = "%s,%s" % (encode(obj.wiz_name), state_name) + + def_params = { + 'string': ('wizard_field', lambda s: [encode(s)]), + 'selection': ('selection', lambda s: [encode(e[1]) for e in s]), + 'help': ('help', lambda s: [encode(s)]), + } # export fields for field_name, field_def in result['fields'].iteritems(): res_name = name + ',' + field_name - if 'string' in field_def: - source = field_def['string'] - push_translation(module, 'wizard_field', res_name, 0, source.encode('utf8')) - - if 'selection' in field_def: - for key, val in field_def['selection']: - push_translation(module, 'selection', res_name, 0, val.encode('utf8')) + + for fn in def_params: + if fn in field_def: + transtype, modifier = def_params[fn] + for val in modifier(field_def[fn]): + push_translation(module, transtype, res_name, 0, val) # export arch arch = result['arch'] @@ -386,17 +398,17 @@ def trans_generate(lang, modules, dbname=None): push_translation(module, 'wizard_button', res_name, 0, button_label) elif model=='ir.model.fields': - field_name = obj.name + field_name = encode(obj.name) objmodel = pool.get(obj.model) if not objmodel or not field_name in objmodel._columns: continue field_def = objmodel._columns[field_name] - name = obj.model + "," + field_name - push_translation(module, 'field', name, 0, field_def.string.encode('utf8')) + name = "%s,%s" % (encode(obj.model), field_name) + push_translation(module, 'field', name, 0, encode(field_def.string)) if field_def.help: - push_translation(module, 'help', name, 0, field_def.help.encode('utf8')) + push_translation(module, 'help', name, 0, encode(field_def.help)) if field_def.translate: ids = objmodel.search(cr, uid, []) @@ -410,14 +422,14 @@ def trans_generate(lang, modules, dbname=None): ('res_id', '=', res_id), ]) if not model_data_ids: - push_translation(module, 'model', name, 0, obj_value[field_name]) + push_translation(module, 'model', name, 0, encode(obj_value[field_name])) if hasattr(field_def, 'selection') and isinstance(field_def.selection, (list, tuple)): for key, val in field_def.selection: - push_translation(module, 'selection', name, 0, val.encode('utf8')) + push_translation(module, 'selection', name, 0, encode(val)) elif model=='ir.actions.report.xml': - name = obj.report_name + name = encode(obj.report_name) fname = "" if obj.report_rml: fname = obj.report_rml @@ -438,13 +450,13 @@ def trans_generate(lang, modules, dbname=None): for constraint in pool.get(model)._constraints: msg = constraint[1] - push_translation(module, 'constraint', model, 0, msg.encode('utf8')) + push_translation(module, 'constraint', model, 0, encode(msg)) for field_name,field_def in pool.get(model)._columns.items(): if field_def.translate: name = model + "," + field_name trad = getattr(obj, field_name) or '' - push_translation(module, 'model', name, xml_name, trad) + push_translation(module, 'model', name, xml_name, encode(trad)) # parse source code for _() calls def get_module_from_path(path): @@ -470,14 +482,17 @@ def trans_generate(lang, modules, dbname=None): '[^a-zA-Z0-9_]_\([\s]*["\'](.+?)["\'][\s]*\)', code_string, re.M) for i in iter: - push_translation(module, 'code', frelativepath, 0, i.group(1).encode('utf8')) + push_translation(module, 'code', frelativepath, 0, encode(i.group(1))) out = [["module","type","name","res_id","src","value"]] # header # translate strings marked as to be translated for module, type, name, id, source in _to_translate: trans = trans_obj._get_source(cr, uid, name, type, lang, source) - out.append([module, type, name, id, source, trans or '']) + out.append([module, type, name, id, source, encode(trans) or '']) + + from pprint import pformat + netsvc.Logger().notifyChannel('translation', netsvc.LOG_DEBUG, pformat(filter(lambda o:any(isinstance(x, unicode) for x in o), out))) cr.close() return out @@ -492,7 +507,7 @@ def trans_load(db_name, filename, lang, strict=False, verbose=True): return r except IOError: if verbose: - logger.notifyChannel("init", netsvc.LOG_ERROR, "couldn't read translation file %s" % (filename,)) # FIXME translate message + logger.notifyChannel("init", netsvc.LOG_ERROR, "couldn't read translation file %s" % (filename,)) return None def trans_load_data(db_name, fileobj, fileformat, lang, strict=False, lang_name=None, verbose=True): diff --git a/bin/wizard/__init__.py b/bin/wizard/__init__.py index fcacf67a476..8996ce0cb80 100644 --- a/bin/wizard/__init__.py +++ b/bin/wizard/__init__.py @@ -113,15 +113,22 @@ class interface(netsvc.Service): if lang: # translate fields for field in fields: - trans = translate(cr, self.wiz_name+','+state+','+field, 'wizard_field', lang) + res_name = "%s,%s,%s" % (self.wiz_name, state, field) + + trans = translate(cr, res_name, 'wizard_field', lang) if trans: fields[field]['string'] = trans if 'selection' in fields[field]: - trans = lambda x: translate(cr, self.wiz_name+','+state+','+field, 'selection', lang, x) or x + trans = lambda x: translate(cr, res_name, 'selection', lang, x) or x for idx, (key, val) in enumerate(fields[field]['selection']): fields[field]['selection'][idx] = (key, trans(val)) + if 'help' in fields[field]: + t = translate(cr, res_name, 'help', lang, fields[field]['help']) + if t: + fields[field]['help'] = t + # translate arch if not isinstance(arch, UpdateableStr): doc = dom.minidom.parseString(arch) From 779b8ff618664147f9c40eab82a730bd21275318 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Tue, 16 Dec 2008 19:10:07 +0100 Subject: [PATCH 27/29] [IMP] Use the PEP8 specification for the import bzr revid: stephane@tinyerp.com-20081216181007-0gsqhlaqnuebdpfg --- bin/tools/config.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/tools/config.py b/bin/tools/config.py index 224ac5e4e72..1d5a3372537 100644 --- a/bin/tools/config.py +++ b/bin/tools/config.py @@ -20,8 +20,12 @@ # ############################################################################## -import ConfigParser,optparse,os,sys -import netsvc,logging +import ConfigParser +import optparse +import os +import sys +import netsvc +import logging import release class configmanager(object): From 33cbc4a44caff8d2c920db0d3fdc960ffa02a43b Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 16 Dec 2008 19:15:35 +0100 Subject: [PATCH 28/29] improved bzr revid: fp@tinyerp.com-20081216181535-uplb4qy6omlm1k33 --- bin/addons/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index eec3f6b2370..75f4fee3184 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -545,11 +545,11 @@ def load_modules(db, force_demo=False, status=None, update_module=False): status={} cr = db.cursor() + force = [] + if force_demo: + force.append('demo') + pool = pooler.get_pool(cr.dbname) try: - force = [] - if force_demo: - force.append('demo') - pool = pooler.get_pool(cr.dbname) report = tools.assertion_report() if update_module: basegraph = create_graph(['base'], force) From 3ee905239b37c0cf86ae7cb3917f4d7765fa9e95 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 16 Dec 2008 19:58:24 +0100 Subject: [PATCH 29/29] improved_bugfix bzr revid: fp@tinyerp.com-20081216185824-stl92nzt3ij0zhf7 --- bin/osv/fields.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/osv/fields.py b/bin/osv/fields.py index e0da8d38945..6b86eb7bc7a 100644 --- a/bin/osv/fields.py +++ b/bin/osv/fields.py @@ -699,7 +699,11 @@ class related(function): for i in range(len(self.arg)): field_detail = self._relations[i] relation = field_detail['object'] - if not t_data[self.arg[i]]: + try: + if not t_data[self.arg[i]]: + t_data = False + break + except: t_data = False break if field_detail['type'] in ('one2many', 'many2many'):