diff --git a/addons/account/account.py b/addons/account/account.py index 90d7e2c0d95..837edaae195 100644 --- a/addons/account/account.py +++ b/addons/account/account.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$ # @@ -282,7 +282,9 @@ class account_account(osv.osv): required=True), 'check_history': fields.boolean('Display History', help="Check this box if you want to print all entries when printing the General Ledger, "\ - "otherwise it will only print its balance.") + "otherwise it will only print its balance."), + 'merge_invoice': fields.boolean('Merge Invoice Entries',help="Check this box if you want that all lines of "\ + "a customer or supplier invoice using this account are created in one line only"), } def _default_company(self, cr, uid, context={}): diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 64b19713e5b..2b0a8aee54d 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.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$ # @@ -176,7 +176,7 @@ class account_move_line(osv.osv): if s>0: acc = acc1 v = self.pool.get('res.currency').compute(cr, uid, - account.company_id.currency_id.id, + account.company_id.currency_id.id, data['currency_id'], s, account=acc, account_invert=True) data['amount_currency'] = v @@ -277,7 +277,7 @@ class account_move_line(osv.osv): _columns = { 'name': fields.char('Name', size=64, required=True), - 'quantity': fields.float('Quantity', digits=(16,2), help="The optionnal quantity expressed by this line, eg: number of product sold. The quantity is not a legal requirement but is very usefull for some reports."), + 'quantity': fields.float('Quantity', digits=(16,2), help="The optional quantity expressed by this line, eg: number of product sold. The quantity is not a legal requirement but is very usefull for some reports."), 'debit': fields.float('Debit', digits=(16,2)), 'credit': fields.float('Credit', digits=(16,2)), 'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", domain=[('type','<>','view'), ('type', '<>', 'closed')], select=2), diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 4e51b8c99b9..e26f3870516 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -130,6 +130,7 @@ + @@ -988,17 +989,17 @@ diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 5690102c8df..5c887064f1e 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.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$ # @@ -414,6 +414,7 @@ class account_invoice(osv.osv): def action_move_create(self, cr, uid, ids, *args): ait_obj = self.pool.get('account.invoice.tax') cur_obj = self.pool.get('res.currency') + acc_obj = self.pool.get('account.account') for inv in self.browse(cr, uid, ids): if inv.move_id: continue @@ -460,7 +461,11 @@ class account_invoice(osv.osv): # create one move line for the total and possibly adjust the other lines amount total = 0 total_currency = 0 + key_line=[] for i in iml: + if i.has_key('account_id') and i.has_key('taxes'): + 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: i['currency_id'] = inv.currency_id.id i['amount_currency'] = i['price'] @@ -481,6 +486,36 @@ class account_invoice(osv.osv): acc_id = inv.account_id.id name = inv['name'] or '/' + iml_temp=[] + move_list=[] + + for item in key_line: + move_temp={} + 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]): + move_list.append(move_line) + if repeat: + for key in move_line: + if key in ['name','amount_currency','price_unit','price','quantity']: + if key=='name': + move_temp[key]=move_temp[key] + "," +move_line[key] + else: + move_temp[key] +=move_line[key] + else: + for key in move_line: + move_temp[key]=move_line[key] + repeat=True + if move_temp: + iml_temp.append(move_temp) + + if len(iml_temp) + + + + + + @@ -125,6 +131,15 @@ + + +