From 83d2edd8c0a58f670810e4a7bc8a1280cfa57f67 Mon Sep 17 00:00:00 2001 From: Harshad Modi Date: Tue, 11 Nov 2008 10:57:50 +0530 Subject: [PATCH 1/6] fixed Bug #296100 bzr revid: hmo@tinyerp.com-20081111052750-zqzvr6oaihvt103t --- addons/document/document.py | 39 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/addons/document/document.py b/addons/document/document.py index 79d8960363b..31de70cc63f 100644 --- a/addons/document/document.py +++ b/addons/document/document.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$ # @@ -74,28 +74,29 @@ class node_class(object): if self.object2: where.append( ('res_model','=',self.object2._name) ) where.append( ('res_id','=',self.object2.id) ) - for content in self.object.content_ids: - if self.object2 or not content.include_name: - if content.include_name: - test_nodename = self.object2.name + (content.suffix or '') + (content.extension or '') - else: - test_nodename = (content.suffix or '') + (content.extension or '') - if test_nodename.find('/'): - test_nodename=test_nodename.replace('/', '_') - path = self.path+'/'+test_nodename - #path = self.path+'/'+self.object2.name + (content.suffix or '') + (content.extension or '') - if not nodename: - n = node_class(self.cr, self.uid,path, self.object2, False, content=content, type='content', root=False) - res2.append( n) - else: - if nodename == test_nodename: - n = node_class(self.cr, self.uid, path, self.object2, False, content=content, type='content', root=False) - res2.append(n) + for content in self.object.content_ids: + if self.object2 or not content.include_name: + if content.include_name: + test_nodename = self.object2.name + (content.suffix or '') + (content.extension or '') + else: + test_nodename = (content.suffix or '') + (content.extension or '') + if test_nodename.find('/'): + test_nodename=test_nodename.replace('/', '_') + path = self.path+'/'+test_nodename + #path = self.path+'/'+self.object2.name + (content.suffix or '') + (content.extension or '') + if not nodename: + n = node_class(self.cr, self.uid,path, self.object2, False, content=content, type='content', root=False) + res2.append( n) + else: + if nodename == test_nodename: + n = node_class(self.cr, self.uid, path, self.object2, False, content=content, type='content', root=False) + res2.append(n) else: where.append( ('parent_id','=',self.object.id) ) where.append( ('res_id','=',False) ) if nodename: where.append( (fobj._rec_name,'=',nodename) ) + print where+[ ('parent_id','=',self.object and self.object.id or False) ] ids = fobj.search(self.cr, self.uid, where+[ ('parent_id','=',self.object and self.object.id or False) ], context=self.context) if self.object and self.root and (self.object.type=='ressource'): ids += fobj.search(self.cr, self.uid, where+[ ('parent_id','=',False) ], context=self.context) @@ -560,6 +561,7 @@ class document_file(osv.osv): if not self._check_duplication(cr,uid,vals): raise except_orm('ValidateError', 'File name must be unique!') result = super(document_file,self).write(cr,uid,ids,vals,context=context) + cr.commit() try: for f in self.browse(cr, uid, ids, context=context): if 'datas' not in vals: @@ -568,6 +570,7 @@ class document_file(osv.osv): super(document_file,self).write(cr, uid, ids, { 'index_content': res }) + cr.commit() except: pass return result From 14bc1b8b7346716e7dad269243ebd6d2424a824a Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Tue, 11 Nov 2008 12:27:10 +0530 Subject: [PATCH 2/6] account : advance refund invoice bzr revid: mra@tinyerp.com-20081111065710-fbsflhc26v6p5ee0 --- addons/account/invoice.py | 23 ++- addons/account/wizard/wizard_refund.py | 200 ++++++++++++++++++++++--- 2 files changed, 199 insertions(+), 24 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 23544989049..d346a5824fe 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -718,9 +718,15 @@ class account_invoice(osv.osv): line['invoice_line_tax_id'] = [(6,0, line.get('invoice_line_tax_id', [])) ] if 'account_analytic_id' in line: line['account_analytic_id'] = line.get('account_analytic_id', False) and line['account_analytic_id'][0] + if 'tax_code_id' in line : + if isinstance(line['tax_code_id'],tuple) and len(line['tax_code_id']) >0 : + line['tax_code_id'] = line['tax_code_id'][0] + if 'base_code_id' in line : + if isinstance(line['base_code_id'],tuple) and len(line['base_code_id']) >0 : + line['base_code_id'] = line['base_code_id'][0] return map(lambda x: (0,0,x), lines) - def refund(self, cr, uid, ids): + def refund(self, cr, uid, ids, date=None, period_id=None, description=None): invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'address_contact_id', 'address_invoice_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id']) new_ids = [] @@ -741,21 +747,28 @@ class account_invoice(osv.osv): tax_lines = self.pool.get('account.invoice.tax').read(cr, uid, invoice['tax_line']) tax_lines = filter(lambda l: l['manual'], tax_lines) tax_lines = self._refund_cleanup_lines(tax_lines) - + if not date : + date = time.strftime('%Y-%m-%d') invoice.update({ 'type': type_dict[invoice['type']], - 'date_invoice': time.strftime('%Y-%m-%d'), + 'date_invoice': date, 'state': 'draft', 'number': False, 'invoice_line': invoice_lines, 'tax_line': tax_lines }) - + if period_id : + invoice.update({ + 'period_id': period_id, + }) + if description : + invoice.update({ + 'name': description, + }) # take the id part of the tuple returned for many2one fields for field in ('address_contact_id', 'address_invoice_id', 'partner_id', 'account_id', 'currency_id', 'payment_term', 'journal_id'): invoice[field] = invoice[field] and invoice[field][0] - # create the new invoice new_ids.append(self.create(cr, uid, invoice)) return new_ids diff --git a/addons/account/wizard/wizard_refund.py b/addons/account/wizard/wizard_refund.py index 82f3699f37d..687420b5cc7 100644 --- a/addons/account/wizard/wizard_refund.py +++ b/addons/account/wizard/wizard_refund.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$ # @@ -19,44 +19,206 @@ # along with this program. If not, see . # ############################################################################## - import wizard import pooler +import osv +import netsvc +import time sur_form = '''
-