From 8e41226a73df28cb6412e5c7588c243cf094dfb2 Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Thu, 6 Nov 2008 11:22:18 +0530 Subject: [PATCH 1/4] Small changes in account balance bzr revid: patelamit2003@gmail.com-20081106055218-pib4z3u65pco2y1t --- addons/account/report/account_balance.rml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/addons/account/report/account_balance.rml b/addons/account/report/account_balance.rml index 4e77667416f..e4bb97a6602 100755 --- a/addons/account/report/account_balance.rml +++ b/addons/account/report/account_balance.rml @@ -98,6 +98,12 @@ + + + + + + @@ -125,6 +131,15 @@ + + + Date: Thu, 6 Nov 2008 12:59:50 +0530 Subject: [PATCH 2/4] Added merging invoice entries functionality bzr revid: jvo@tinyerp.com-20081106072950-u1flmnk52gg1hfd0 --- addons/account/account.py | 6 +++-- addons/account/account_move_line.py | 6 ++--- addons/account/account_view.xml | 15 ++++++----- addons/account/invoice.py | 41 +++++++++++++++++++++++++++-- 4 files changed, 54 insertions(+), 14 deletions(-) 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) Date: Thu, 6 Nov 2008 13:07:54 +0530 Subject: [PATCH 3/4] bug fix in third party ledger bzr revid: patelamit2003@gmail.com-20081106073754-htbzyzvqcjvm05o2 --- addons/account/report/third_party_ledger.py | 73 ++++++++++--------- .../wizard/wizard_third_party_ledger.py | 2 +- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/addons/account/report/third_party_ledger.py b/addons/account/report/third_party_ledger.py index 050d33be1aa..d2839027fb2 100755 --- a/addons/account/report/third_party_ledger.py +++ b/addons/account/report/third_party_ledger.py @@ -184,7 +184,8 @@ class third_party_ledger(rml_parse.rml_parse): partner_to_use = [] if data['form']['soldeinit'] : - + print"self.date_lst[0]",self.date_lst[0] + print"self.date_lst[len(self.date_lst)-1]",self.date_lst[len(self.date_lst)-1] self.cr.execute( "SELECT DISTINCT line.partner_id " \ "FROM account_move_line AS line, account_account AS account " \ @@ -198,22 +199,22 @@ class third_party_ledger(rml_parse.rml_parse): "AND account.company_id = %d " \ "AND account.active " , (self.date_lst[0],self.date_lst[len(self.date_lst)-1],data['form']['company_id'])) - else: - - self.cr.execute( - "SELECT DISTINCT line.partner_id " \ - "FROM account_move_line AS line, account_account AS account " \ - "WHERE line.partner_id IS NOT NULL " \ - "AND line.account_id = account.id " \ - "AND line.date IN (" + self.date_lst_string + ") " \ - "AND line.account_id IN (" + self.account_ids + ") " \ - " " + PARTNER_REQUEST + " " \ - "AND account.company_id = %d " \ - "AND account.active " , - (data['form']['company_id'])) +# else: +# +# self.cr.execute( +# "SELECT DISTINCT line.partner_id " \ +# "FROM account_move_line AS line, account_account AS account " \ +# "WHERE line.partner_id IS NOT NULL " \ +# "AND line.account_id = account.id " \ +# "AND line.date IN (" + self.date_lst_string + ") " \ +# "AND line.account_id IN (" + self.account_ids + ") " \ +# " " + PARTNER_REQUEST + " " \ +# "AND account.company_id = %d " \ +# "AND account.active " , +# (data['form']['company_id'])) res = self.cr.dictfetchall() - + print"=====res====",res for res_line in res: partner_to_use.append(res_line['partner_id']) new_ids = partner_to_use @@ -229,26 +230,26 @@ class third_party_ledger(rml_parse.rml_parse): RECONCILE_TAG = " " else: RECONCILE_TAG = "AND l.reconcile_id IS NULL" - if data['form']['soldeinit'] : - - self.cr.execute( - "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \ - "FROM account_move_line l " \ - "LEFT JOIN account_journal j " \ - "ON (l.journal_id = j.id) " \ - "WHERE l.partner_id = %d " \ - "AND l.account_id IN (" + self.account_ids + ") " \ - "AND l.date <= %s " \ - "AND l.reconcile_id IS NULL " - "ORDER BY l.id", - (partner.id, self.date_lst[0])) - res = self.cr.dictfetchall() - - sum = 0.0 - for r in res: - sum = r['debit'] - r['credit'] - r['progress'] = sum - full_account.append(r) +# if data['form']['soldeinit'] : +# +# self.cr.execute( +# "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \ +# "FROM account_move_line l " \ +# "LEFT JOIN account_journal j " \ +# "ON (l.journal_id = j.id) " \ +# "WHERE l.partner_id = %d " \ +# "AND l.account_id IN (" + self.account_ids + ") " \ +# "AND l.date <= %s " \ +# "AND l.reconcile_id IS NULL " +# "ORDER BY l.id", +# (partner.id, self.date_lst[0])) +# res = self.cr.dictfetchall() +# print"----res----",res +# sum = 0.0 +# for r in res: +# sum = r['debit'] - r['credit'] +# r['progress'] = sum +# full_account.append(r) self.cr.execute( "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \ @@ -262,7 +263,7 @@ class third_party_ledger(rml_parse.rml_parse): "ORDER BY l.id", (partner.id,)) res = self.cr.dictfetchall() - + print":::::res::::::",res sum = 0.0 for r in res: sum = r['debit'] - r['credit'] diff --git a/addons/account/wizard/wizard_third_party_ledger.py b/addons/account/wizard/wizard_third_party_ledger.py index 72aece90c41..6497958fee6 100755 --- a/addons/account/wizard/wizard_third_party_ledger.py +++ b/addons/account/wizard/wizard_third_party_ledger.py @@ -119,7 +119,7 @@ class wizard_report(wizard.interface): def _check_state(self, cr, uid, data, context): - if data['form']['state'] == 'bydate' or data['form']['state'] == 'all': + if data['form']['state'] == 'bydate' or data['form']['state'] == 'all' or data['form']['state'] == 'none': data['form']['fiscalyear'] = False else : data['form']['fiscalyear'] = True From d2c3be7c9dfda086975e6c96e17eff16bfa3829f Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Thu, 6 Nov 2008 13:12:11 +0530 Subject: [PATCH 4/4] remove print bzr revid: patelamit2003@gmail.com-20081106074211-f28x67fpnmmrglxv --- addons/account/report/third_party_ledger.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/account/report/third_party_ledger.py b/addons/account/report/third_party_ledger.py index d2839027fb2..5c8132082d9 100755 --- a/addons/account/report/third_party_ledger.py +++ b/addons/account/report/third_party_ledger.py @@ -184,8 +184,7 @@ class third_party_ledger(rml_parse.rml_parse): partner_to_use = [] if data['form']['soldeinit'] : - print"self.date_lst[0]",self.date_lst[0] - print"self.date_lst[len(self.date_lst)-1]",self.date_lst[len(self.date_lst)-1] + self.cr.execute( "SELECT DISTINCT line.partner_id " \ "FROM account_move_line AS line, account_account AS account " \ @@ -214,7 +213,7 @@ class third_party_ledger(rml_parse.rml_parse): # (data['form']['company_id'])) res = self.cr.dictfetchall() - print"=====res====",res + for res_line in res: partner_to_use.append(res_line['partner_id']) new_ids = partner_to_use @@ -263,7 +262,7 @@ class third_party_ledger(rml_parse.rml_parse): "ORDER BY l.id", (partner.id,)) res = self.cr.dictfetchall() - print":::::res::::::",res + sum = 0.0 for r in res: sum = r['debit'] - r['credit']