From aad1541244d04312c218b2e9bbeb4054204849e1 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Mon, 28 Nov 2011 18:31:57 +0530 Subject: [PATCH 01/22] [FIX] account : Cost Ledger Incorrect For View Accounts lp bug: https://launchpad.net/bugs/880844 fixed bzr revid: mdi@tinyerp.com-20111128130157-jo9e7g08gmro7zpp --- addons/account/project/report/cost_ledger.py | 46 +++++++++++++++----- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/addons/account/project/report/cost_ledger.py b/addons/account/project/report/cost_ledger.py index 225a85d2ee1..f571c5328bf 100644 --- a/addons/account/project/report/cost_ledger.py +++ b/addons/account/project/report/cost_ledger.py @@ -38,11 +38,32 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): 'sum_balance': self._sum_balance, }) + def _get_children(self, account_id): + result = [] + + def _get_rec(account_id): + analytic_obj = self.pool.get('account.analytic.account') + analytic_search_ids = analytic_obj.search(self.cr, self.uid, [('id', '=', account_id)]) + analytic_datas = analytic_obj.browse(self.cr, self.uid, analytic_search_ids) + + result.append(account_id) + for account in analytic_datas: + for child in account.child_ids: + result.append(child.id) + for child_id in child.child_ids: + _get_rec(child_id.id) + return result + + child_ids = _get_rec(account_id) + + return child_ids + def _lines_g(self, account_id, date1, date2): + chid_ids = self._get_children(account_id) self.cr.execute("SELECT sum(aal.amount) AS balance, aa.code AS code, aa.name AS name, aa.id AS id \ FROM account_account AS aa, account_analytic_line AS aal \ - WHERE (aal.account_id=%s) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) AND aa.active \ - GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (account_id, date1, date2)) + WHERE (aal.account_id IN %s) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) AND aa.active \ + GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (tuple(chid_ids), date1, date2)) res = self.cr.dictfetchall() for r in res: @@ -58,10 +79,11 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): return res def _lines_a(self, general_account_id, account_id, date1, date2): + chid_ids = self._get_children(account_id) self.cr.execute("SELECT aal.name AS name, aal.code AS code, aal.amount AS balance, aal.date AS date, aaj.code AS cj FROM account_analytic_line AS aal, account_analytic_journal AS aaj \ - WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) AND (aal.date>=%s) AND (aal.date<=%s) \ + WHERE (aal.general_account_id=%s) AND (aal.account_id IN %s) AND (aal.date>=%s) AND (aal.date<=%s) \ AND (aal.journal_id=aaj.id) \ - ORDER BY aal.date, aaj.code, aal.code", (general_account_id, account_id, date1, date2)) + ORDER BY aal.date, aaj.code, aal.code", (general_account_id, tuple(chid_ids), date1, date2)) res = self.cr.dictfetchall() for r in res: @@ -77,11 +99,13 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): return res def _account_sum_debit(self, account_id, date1, date2): - self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id=%s AND date>=%s AND date<=%s AND amount>0", (account_id, date1, date2)) + chid_ids = self._get_children(account_id) + self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(chid_ids), date1, date2)) return self.cr.fetchone()[0] or 0.0 def _account_sum_credit(self, account_id, date1, date2): - self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id=%s AND date>=%s AND date<=%s AND amount<0", (account_id, date1, date2)) + chid_ids = self._get_children(account_id) + self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(chid_ids), date1, date2)) return self.cr.fetchone()[0] or 0.0 def _account_sum_balance(self, account_id, date1, date2): @@ -91,16 +115,18 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): def _sum_debit(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) - if not ids: + chid_ids = self._get_children(ids[0]) + if not children: return 0.0 - self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(ids), date1, date2,)) + self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(chid_ids), date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_credit(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) - if not ids: + chid_ids = self._get_children(ids[0]) + if not children: return 0.0 - self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(ids),date1, date2,)) + self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(chid_ids),date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_balance(self, accounts, date1, date2): From 1f3a05874455dfb9416abdde35786b59637d63a2 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Wed, 30 Nov 2011 11:45:27 +0530 Subject: [PATCH 02/22] [IMP] account : Improved the code bzr revid: mdi@tinyerp.com-20111130061527-6aklmw9ejnu23dh1 --- addons/account/project/report/cost_ledger.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/account/project/report/cost_ledger.py b/addons/account/project/report/cost_ledger.py index f571c5328bf..88d5e6041f6 100644 --- a/addons/account/project/report/cost_ledger.py +++ b/addons/account/project/report/cost_ledger.py @@ -50,8 +50,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): for account in analytic_datas: for child in account.child_ids: result.append(child.id) - for child_id in child.child_ids: - _get_rec(child_id.id) + _get_rec(child.id) return result child_ids = _get_rec(account_id) @@ -116,7 +115,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): def _sum_debit(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) chid_ids = self._get_children(ids[0]) - if not children: + if not chid_ids: return 0.0 self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(chid_ids), date1, date2,)) return self.cr.fetchone()[0] or 0.0 @@ -124,7 +123,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): def _sum_credit(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) chid_ids = self._get_children(ids[0]) - if not children: + if not chid_ids: return 0.0 self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(chid_ids),date1, date2,)) return self.cr.fetchone()[0] or 0.0 From a01b90fa470afb4bbc3b3eb9b228fe55072ae293 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Wed, 30 Nov 2011 17:48:38 +0530 Subject: [PATCH 03/22] [IMP] account : Improved the code bzr revid: mdi@tinyerp.com-20111130121838-o6nlc4j64y3b3nca --- addons/account/project/report/cost_ledger.py | 30 ++++++++------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/addons/account/project/report/cost_ledger.py b/addons/account/project/report/cost_ledger.py index 88d5e6041f6..9955d1ccffe 100644 --- a/addons/account/project/report/cost_ledger.py +++ b/addons/account/project/report/cost_ledger.py @@ -39,23 +39,17 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): }) def _get_children(self, account_id): + analytic_obj = self.pool.get('account.analytic.account') + if not isinstance(account_id, list): + account_id = [account_id] + search_ids = analytic_obj.search(self.cr, self.uid, [('parent_id', 'child_of', account_id)]) result = [] - - def _get_rec(account_id): - analytic_obj = self.pool.get('account.analytic.account') - analytic_search_ids = analytic_obj.search(self.cr, self.uid, [('id', '=', account_id)]) - analytic_datas = analytic_obj.browse(self.cr, self.uid, analytic_search_ids) - - result.append(account_id) - for account in analytic_datas: - for child in account.child_ids: - result.append(child.id) - _get_rec(child.id) - return result - - child_ids = _get_rec(account_id) - - return child_ids + for rec in analytic_obj.browse(self.cr, self.uid, search_ids): + for child in rec.child_ids: + result.append(child.id) + if result: + result = self._get_children(result) + return search_ids + result def _lines_g(self, account_id, date1, date2): chid_ids = self._get_children(account_id) @@ -114,7 +108,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): def _sum_debit(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) - chid_ids = self._get_children(ids[0]) + chid_ids = self._get_children(ids) if not chid_ids: return 0.0 self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(chid_ids), date1, date2,)) @@ -122,7 +116,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): def _sum_credit(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) - chid_ids = self._get_children(ids[0]) + chid_ids = self._get_children(ids) if not chid_ids: return 0.0 self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(chid_ids),date1, date2,)) From 888b061c27203e398190f137b08687bb0b5c0e48 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Fri, 2 Dec 2011 16:06:41 +0530 Subject: [PATCH 04/22] [IMP] account : Improved the code bzr revid: mdi@tinyerp.com-20111202103641-2lr29zvdhrbri8xs --- addons/account/project/report/cost_ledger.py | 28 +++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/addons/account/project/report/cost_ledger.py b/addons/account/project/report/cost_ledger.py index 9955d1ccffe..2753b541f6b 100644 --- a/addons/account/project/report/cost_ledger.py +++ b/addons/account/project/report/cost_ledger.py @@ -26,6 +26,7 @@ from report import report_sxw class account_analytic_cost_ledger(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(account_analytic_cost_ledger, self).__init__(cr, uid, name, context=context) + self.analytic_acc_ids = [], self.localcontext.update( { 'time': time, 'lines_g': self._lines_g, @@ -49,14 +50,14 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): result.append(child.id) if result: result = self._get_children(result) - return search_ids + result + self.analytic_acc_ids = search_ids + result + return self.analytic_acc_ids def _lines_g(self, account_id, date1, date2): - chid_ids = self._get_children(account_id) self.cr.execute("SELECT sum(aal.amount) AS balance, aa.code AS code, aa.name AS name, aa.id AS id \ FROM account_account AS aa, account_analytic_line AS aal \ WHERE (aal.account_id IN %s) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) AND aa.active \ - GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (tuple(chid_ids), date1, date2)) + GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (tuple(self.analytic_acc_ids), date1, date2)) res = self.cr.dictfetchall() for r in res: @@ -72,11 +73,10 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): return res def _lines_a(self, general_account_id, account_id, date1, date2): - chid_ids = self._get_children(account_id) self.cr.execute("SELECT aal.name AS name, aal.code AS code, aal.amount AS balance, aal.date AS date, aaj.code AS cj FROM account_analytic_line AS aal, account_analytic_journal AS aaj \ WHERE (aal.general_account_id=%s) AND (aal.account_id IN %s) AND (aal.date>=%s) AND (aal.date<=%s) \ AND (aal.journal_id=aaj.id) \ - ORDER BY aal.date, aaj.code, aal.code", (general_account_id, tuple(chid_ids), date1, date2)) + ORDER BY aal.date, aaj.code, aal.code", (general_account_id, tuple(self.analytic_acc_ids), date1, date2)) res = self.cr.dictfetchall() for r in res: @@ -92,13 +92,11 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): return res def _account_sum_debit(self, account_id, date1, date2): - chid_ids = self._get_children(account_id) - self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(chid_ids), date1, date2)) + self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(self.analytic_acc_ids), date1, date2)) return self.cr.fetchone()[0] or 0.0 def _account_sum_credit(self, account_id, date1, date2): - chid_ids = self._get_children(account_id) - self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(chid_ids), date1, date2)) + self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(self.analytic_acc_ids), date1, date2)) return self.cr.fetchone()[0] or 0.0 def _account_sum_balance(self, account_id, date1, date2): @@ -108,18 +106,16 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): def _sum_debit(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) - chid_ids = self._get_children(ids) - if not chid_ids: + self.analytic_acc_ids = self._get_children(ids) + if not self.analytic_acc_ids: return 0.0 - self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(chid_ids), date1, date2,)) + self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(self.analytic_acc_ids), date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_credit(self, accounts, date1, date2): - ids = map(lambda x: x.id, accounts) - chid_ids = self._get_children(ids) - if not chid_ids: + if not self.analytic_acc_ids: return 0.0 - self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(chid_ids),date1, date2,)) + self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(self.analytic_acc_ids),date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_balance(self, accounts, date1, date2): From cad6715087c0a7a249ccc0566e1dbcc3f9ae4c64 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Mon, 16 Jan 2012 18:04:45 +0530 Subject: [PATCH 05/22] [FIX] account_voucher : Advanced payment+customer credit, wrong open balance lp bug: https://launchpad.net/bugs/901089 fixed bzr revid: mdi@tinyerp.com-20120116123445-5vogciqrwotteq5r --- addons/account_voucher/account_voucher.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 1f8c86161c1..50cde3a2c01 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -593,10 +593,6 @@ class account_voucher(osv.osv): account_move_lines = move_line_pool.browse(cr, uid, ids, context=context) for line in account_move_lines: - if line.credit and line.reconcile_partial_id and ttype == 'receipt': - continue - if line.debit and line.reconcile_partial_id and ttype == 'payment': - continue if invoice_id: if line.invoice.id == invoice_id: #if the invoice linked to the voucher line is equal to the invoice_id in context @@ -622,10 +618,6 @@ class account_voucher(osv.osv): #voucher line creation for line in account_move_lines: - if line.credit and line.reconcile_partial_id and ttype == 'receipt': - continue - if line.debit and line.reconcile_partial_id and ttype == 'payment': - continue if line.currency_id and currency_id==line.currency_id.id: amount_original = abs(line.amount_currency) amount_unreconciled = abs(line.amount_residual_currency) @@ -1051,7 +1043,7 @@ class account_voucher(osv.osv): voucher_currency = voucher_brw.currency_id and voucher_brw.currency_id.id or voucher_brw.journal_id.company_id.currency_id.id # We want to set it on the account move line as soon as the original line had a foreign currency if line.move_line_id.currency_id and line.move_line_id.currency_id.id != company_currency: - # we compute the amount in that foreign currency. + # we compute the amount in that foreign currency. if line.move_line_id.currency_id.id == current_currency: # if the voucher and the voucher line share the same currency, there is no computation to do sign = (move_line['debit'] - move_line['credit']) < 0 and -1 or 1 @@ -1270,7 +1262,7 @@ class account_voucher_line(osv.osv): def _currency_id(self, cr, uid, ids, name, args, context=None): ''' - This function returns the currency id of a voucher line. It's either the currency of the + This function returns the currency id of a voucher line. It's either the currency of the associated move line (if any) or the currency of the voucher or the company currency. ''' res = {} From 3e1a36941cc144a03def51892457fc7683d60bc8 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 3 Feb 2012 12:08:54 +0100 Subject: [PATCH 06/22] [IMP] account: fix, simplify and optimize Cost Ledger bzr revid: rco@openerp.com-20120203110854-2p0g4gwg01u538ao --- addons/account/project/report/cost_ledger.py | 89 +++++++------------ addons/account/project/report/cost_ledger.rml | 18 ++-- 2 files changed, 42 insertions(+), 65 deletions(-) diff --git a/addons/account/project/report/cost_ledger.py b/addons/account/project/report/cost_ledger.py index 2753b541f6b..c7423675c15 100644 --- a/addons/account/project/report/cost_ledger.py +++ b/addons/account/project/report/cost_ledger.py @@ -26,7 +26,6 @@ from report import report_sxw class account_analytic_cost_ledger(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(account_analytic_cost_ledger, self).__init__(cr, uid, name, context=context) - self.analytic_acc_ids = [], self.localcontext.update( { 'time': time, 'lines_g': self._lines_g, @@ -38,89 +37,67 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): 'sum_credit': self._sum_credit, 'sum_balance': self._sum_balance, }) + self.children = {} # a memo for the method _get_children - def _get_children(self, account_id): + def _get_children(self, accounts): + """ return all children accounts of the given accounts + :param accounts: list of browse records of 'account.analytic.account' + :return: tuple of account ids + """ analytic_obj = self.pool.get('account.analytic.account') - if not isinstance(account_id, list): - account_id = [account_id] - search_ids = analytic_obj.search(self.cr, self.uid, [('parent_id', 'child_of', account_id)]) - result = [] - for rec in analytic_obj.browse(self.cr, self.uid, search_ids): - for child in rec.child_ids: - result.append(child.id) - if result: - result = self._get_children(result) - self.analytic_acc_ids = search_ids + result - return self.analytic_acc_ids + res = set() + for account in accounts: + if account.id not in self.children: + self.children[account.id] = analytic_obj.search(self.cr, self.uid, [('parent_id', 'child_of', [account.id])]) + res.update(self.children[account.id]) + return tuple(res) - def _lines_g(self, account_id, date1, date2): + def _lines_g(self, account, date1, date2): self.cr.execute("SELECT sum(aal.amount) AS balance, aa.code AS code, aa.name AS name, aa.id AS id \ FROM account_account AS aa, account_analytic_line AS aal \ WHERE (aal.account_id IN %s) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) AND aa.active \ - GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (tuple(self.analytic_acc_ids), date1, date2)) + GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (self._get_children([account]), date1, date2)) res = self.cr.dictfetchall() - for r in res: - if r['balance'] > 0: - r['debit'] = r['balance'] - r['credit'] = 0.0 - elif r['balance'] < 0: - r['debit'] = 0.0 - r['credit'] = -r['balance'] - else: - r['debit'] = 0.0 - r['credit'] = 0.0 + r['debit'] = r['balance'] if r['balance'] > 0 else 0.0 + r['credit'] = -r['balance'] if r['balance'] < 0 else 0.0 return res - def _lines_a(self, general_account_id, account_id, date1, date2): + def _lines_a(self, general_account, account, date1, date2): self.cr.execute("SELECT aal.name AS name, aal.code AS code, aal.amount AS balance, aal.date AS date, aaj.code AS cj FROM account_analytic_line AS aal, account_analytic_journal AS aaj \ WHERE (aal.general_account_id=%s) AND (aal.account_id IN %s) AND (aal.date>=%s) AND (aal.date<=%s) \ AND (aal.journal_id=aaj.id) \ - ORDER BY aal.date, aaj.code, aal.code", (general_account_id, tuple(self.analytic_acc_ids), date1, date2)) + ORDER BY aal.date, aaj.code, aal.code", (general_account['id'], self._get_children([account]), date1, date2)) res = self.cr.dictfetchall() - for r in res: - if r['balance'] > 0: - r['debit'] = r['balance'] - r['credit'] = 0.0 - elif r['balance'] < 0: - r['debit'] = 0.0 - r['credit'] = -r['balance'] - else: - r['debit'] = 0.0 - r['credit'] = 0.0 + r['debit'] = r['balance'] if r['balance'] > 0 else 0.0 + r['credit'] = -r['balance'] if r['balance'] < 0 else 0.0 return res - def _account_sum_debit(self, account_id, date1, date2): - self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(self.analytic_acc_ids), date1, date2)) - return self.cr.fetchone()[0] or 0.0 + def _account_sum_debit(self, account, date1, date2): + return self._sum_debit(self, [account], date1, date2) - def _account_sum_credit(self, account_id, date1, date2): - self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(self.analytic_acc_ids), date1, date2)) - return self.cr.fetchone()[0] or 0.0 + def _account_sum_credit(self, account, date1, date2): + return self._sum_credit(self, [account], date1, date2) - def _account_sum_balance(self, account_id, date1, date2): - debit = self._account_sum_debit(account_id, date1, date2) - credit = self._account_sum_credit(account_id, date1, date2) + def _account_sum_balance(self, account, date1, date2): + debit = self._account_sum_debit(account, date1, date2) + credit = self._account_sum_credit(account, date1, date2) return (debit-credit) def _sum_debit(self, accounts, date1, date2): - ids = map(lambda x: x.id, accounts) - self.analytic_acc_ids = self._get_children(ids) - if not self.analytic_acc_ids: - return 0.0 - self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(self.analytic_acc_ids), date1, date2,)) + self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", + (self._get_children(accounts), date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_credit(self, accounts, date1, date2): - if not self.analytic_acc_ids: - return 0.0 - self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(self.analytic_acc_ids),date1, date2,)) + self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", + (self._get_children(accounts), date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_balance(self, accounts, date1, date2): - debit = self._sum_debit(accounts, date1, date2) or 0.0 - credit = self._sum_credit(accounts, date1, date2) or 0.0 + debit = self._sum_debit(accounts, date1, date2) + credit = self._sum_credit(accounts, date1, date2) return (debit-credit) report_sxw.report_sxw('report.account.analytic.account.cost_ledger', 'account.analytic.account', 'addons/account/project/report/cost_ledger.rml',parser=account_analytic_cost_ledger, header="internal") diff --git a/addons/account/project/report/cost_ledger.rml b/addons/account/project/report/cost_ledger.rml index d53467b4e93..7500b655ab3 100644 --- a/addons/account/project/report/cost_ledger.rml +++ b/addons/account/project/report/cost_ledger.rml @@ -229,28 +229,28 @@
- [[ repeatIn(objects,'o') ]] + [[ repeatIn(objects,'account') ]] - [[ o.code ]] + [[ account.code ]] - [[ o.complete_name ]] + [[ account.complete_name ]] - [[ formatLang (account_sum_debit(o.id,data['form']['date1'],data['form']['date2'])) ]] + [[ formatLang (account_sum_debit(account,data['form']['date1'],data['form']['date2'])) ]] - [[ formatLang (account_sum_credit(o.id,data['form']['date1'],data['form']['date2'])) ]] + [[ formatLang (account_sum_credit(account,data['form']['date1'],data['form']['date2'])) ]] - [[ formatLang (account_sum_balance(o.id,data['form']['date1'],data['form']['date2']))]] [[ company.currency_id.symbol ]] + [[ formatLang (account_sum_balance(account,data['form']['date1'],data['form']['date2']))]] [[ company.currency_id.symbol ]]
- [[ repeatIn(lines_g(o.id,data['form']['date1'],data['form']['date2']),'move_g') ]] + [[ repeatIn(lines_g(account,data['form']['date1'],data['form']['date2']),'move_g') ]] @@ -271,7 +271,7 @@
- [[ repeatIn(lines_a(move_g['id'],o.id,data['form']['date1'],data['form']['date2']),'move_a') ]] + [[ repeatIn(lines_a(move_g,account,data['form']['date1'],data['form']['date2']),'move_a') ]] @@ -302,4 +302,4 @@
- \ No newline at end of file + From 590c143fe3a6c99098d64e592126f9e68d1f3e82 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Fri, 24 Feb 2012 10:02:35 +0100 Subject: [PATCH 07/22] [FIX] account_voucher: correct fix for lp:901089 lp bug: https://launchpad.net/bugs/901089 fixed bzr revid: qdp-launchpad@openerp.com-20120224090235-ykpgfsfa3ail0pq7 --- addons/account_voucher/account_voucher.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 50cde3a2c01..50c18e603d2 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -592,7 +592,14 @@ class account_voucher(osv.osv): ids.reverse() account_move_lines = move_line_pool.browse(cr, uid, ids, context=context) + #compute the total debit/credit and look for a matching open amount or invoice for line in account_move_lines: + #if the line is partially reconciled, then we must pay attention to display it only once and in the good o2m + if line.debit and line.reconcile_partial_id and ttype == 'receipt': + continue + if line.credit and line.reconcile_partial_id and ttype == 'payment': + continue + if invoice_id: if line.invoice.id == invoice_id: #if the invoice linked to the voucher line is equal to the invoice_id in context @@ -618,6 +625,12 @@ class account_voucher(osv.osv): #voucher line creation for line in account_move_lines: + #if the line is partially reconciled, then we must pay attention to display it only once and in the good o2m + if line.debit and line.reconcile_partial_id and ttype == 'receipt': + continue + if line.credit and line.reconcile_partial_id and ttype == 'payment': + continue + if line.currency_id and currency_id==line.currency_id.id: amount_original = abs(line.amount_currency) amount_unreconciled = abs(line.amount_residual_currency) From bdf3e9bca3e4c9cfbe2d1e0f15dc75070470ce65 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Fri, 24 Feb 2012 11:23:05 +0100 Subject: [PATCH 08/22] [FIX] account_voucher: correct fix for lp:901089 lp bug: https://launchpad.net/bugs/901089 fixed bzr revid: qdp-launchpad@openerp.com-20120224102305-6yqsk0vaasydcxum --- addons/account_voucher/account_voucher.py | 25 +++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 6253720e094..3ed173cca85 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -547,6 +547,21 @@ class account_voucher(osv.osv): @return: Returns a dict which contains new values, and context """ + def _remove_noise_in_o2m(): + """if the line is partially reconciled, then we must pay attention to display it only once and + in the good o2m. + This function returns True if the line is considered as noise and should not be displayed + """ + if line.reconcile_partial_id: + sign = 1 if ttype == 'receipt' else -1 + if currency_id == line.currency_id.id: + if line.amount_residual_currency * sign <= 0: + return True + else: + if line.amount_residual * sign <= 0: + return True + return False + if context is None: context = {} context_multi_currency = context.copy() @@ -612,10 +627,7 @@ class account_voucher(osv.osv): #compute the total debit/credit and look for a matching open amount or invoice for line in account_move_lines: - #if the line is partially reconciled, then we must pay attention to display it only once and in the good o2m - if line.debit and line.reconcile_partial_id and ttype == 'receipt': - continue - if line.credit and line.reconcile_partial_id and ttype == 'payment': + if _remove_noise_in_o2m(): continue if invoice_id: @@ -643,10 +655,7 @@ class account_voucher(osv.osv): #voucher line creation for line in account_move_lines: - #if the line is partially reconciled, then we must pay attention to display it only once and in the good o2m - if line.debit and line.reconcile_partial_id and ttype == 'receipt': - continue - if line.credit and line.reconcile_partial_id and ttype == 'payment': + if _remove_noise_in_o2m(): continue if line.currency_id and currency_id==line.currency_id.id: From 881ffef8166ba077747c98fda0b22290b8d6534d Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Fri, 24 Feb 2012 12:17:13 +0100 Subject: [PATCH 09/22] [REM] hr_timesheet_invoice: removed unused report cost ledger. It was duplicated code of the same report defined in account module AND calling its rml. bzr revid: qdp-launchpad@openerp.com-20120224111713-d1j8hubz33cx5wyf --- addons/hr_timesheet_invoice/__openerp__.py | 1 - .../hr_timesheet_invoice_report.xml | 2 - .../hr_timesheet_invoice/report/__init__.py | 1 - .../report/cost_ledger.py | 174 -------- .../report/cost_ledger.rml | 404 ------------------ .../test/hr_timesheet_invoice_report.yml | 11 - .../hr_timesheet_invoice/wizard/__init__.py | 1 - ...r_timesheet_analytic_cost_ledger_report.py | 52 --- ...heet_invoice_analytic_cost_ledger_view.xml | 34 -- 9 files changed, 680 deletions(-) delete mode 100644 addons/hr_timesheet_invoice/report/cost_ledger.py delete mode 100644 addons/hr_timesheet_invoice/report/cost_ledger.rml delete mode 100644 addons/hr_timesheet_invoice/wizard/hr_timesheet_analytic_cost_ledger_report.py delete mode 100644 addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_analytic_cost_ledger_view.xml diff --git a/addons/hr_timesheet_invoice/__openerp__.py b/addons/hr_timesheet_invoice/__openerp__.py index 9e8af9aa736..7e11fdad723 100644 --- a/addons/hr_timesheet_invoice/__openerp__.py +++ b/addons/hr_timesheet_invoice/__openerp__.py @@ -42,7 +42,6 @@ reports, etc.""", 'hr_timesheet_invoice_report.xml', 'report/report_analytic_view.xml', 'report/hr_timesheet_invoice_report_view.xml', - 'wizard/hr_timesheet_invoice_analytic_cost_ledger_view.xml', 'wizard/hr_timesheet_analytic_profit_view.xml', 'wizard/hr_timesheet_invoice_create_view.xml', 'wizard/hr_timesheet_invoice_create_final_view.xml', diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice_report.xml b/addons/hr_timesheet_invoice/hr_timesheet_invoice_report.xml index cc8028a8a0a..473820d5123 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice_report.xml +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice_report.xml @@ -1,8 +1,6 @@ - - ). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -import pooler -import time -from report import report_sxw - - -class account_analytic_cost_ledger(report_sxw.rml_parse): - def __init__(self, cr, uid, name, context): - super(account_analytic_cost_ledger, self).__init__(cr, uid, name, context=context) - self.sum_revenue={} - self.account_sum_revenue={} - self.localcontext.update( { - 'time': time, - 'lines_g': self._lines_g, - 'lines_a': self._lines_a, - 'account_sum_debit': self._account_sum_debit, - 'account_sum_credit': self._account_sum_credit, - 'account_sum_balance': self._account_sum_balance, - 'account_sum_qty': self._account_sum_qty, - 'account_sum_revenue': self._account_sum_revenue, - 'account_g_sum_revenue': self._account_g_sum_revenue, - 'sum_debit': self._sum_debit, - 'sum_credit': self._sum_credit, - 'sum_balance': self._sum_balance, - 'sum_qty': self._sum_qty, - 'sum_revenue': self._sum_revenue, - }) - - def _lines_g(self, account_id, date1, date2): - self.cr.execute("SELECT sum(aal.amount) AS balance, aa.code AS code, aa.name AS name, aa.id AS id, sum(aal.unit_amount) AS quantity \ - FROM account_account AS aa, account_analytic_line AS aal \ - WHERE (aal.account_id=%s) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) AND aa.active \ - GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (account_id, date1, date2)) - res = self.cr.dictfetchall() - - for r in res: - if r['balance'] > 0: - r['debit'] = r['balance'] - r['credit'] = 0.0 - elif r['balance'] < 0: - r['debit'] = 0.0 - r['credit'] = -r['balance'] - else: - r['debit'] = 0.0 - r['credit'] = 0.0 - return res - - def _lines_a(self, general_account_id, account_id, date1, date2): - self.cr.execute("SELECT aal.id AS id, aal.name AS name, aal.code AS code, aal.amount AS balance, aal.date AS date, aaj.code AS cj, aal.unit_amount AS quantity \ - FROM account_analytic_line AS aal, account_analytic_journal AS aaj \ - WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) AND (aal.date>=%s) AND (aal.date<=%s) \ - AND (aal.journal_id=aaj.id) \ - ORDER BY aal.date, aaj.code, aal.code", (general_account_id, account_id, date1, date2)) - res = self.cr.dictfetchall() - - line_obj = self.pool.get('account.analytic.line') - price_obj = self.pool.get('product.pricelist') - lines = {} - for l in line_obj.browse(self.cr, self.uid, [ x['id'] for x in res]): - lines[l.id] = l - if not account_id in self.sum_revenue: - self.sum_revenue[account_id] = 0.0 - if not general_account_id in self.account_sum_revenue: - self.account_sum_revenue[general_account_id] = 0.0 - for r in res: - id = r['id'] - revenue = 0.0 - if lines[id].amount < 0 and lines[id].product_id and lines[id].product_uom_id and lines[id].account_id.pricelist_id: - ctx = {'uom': lines[id].product_uom_id.id} - price = price_obj.price_get(self.cr, self.uid, [lines[id].account_id.pricelist_id.id], lines[id].product_id.id, lines[id].unit_amount, False, context=ctx)[lines[id].account_id.pricelist_id.id] - revenue = round(price * lines[id].unit_amount, 2) - r['revenue'] = revenue - self.sum_revenue[account_id] += revenue - self.account_sum_revenue[general_account_id] += revenue - if r['balance'] > 0: - r['debit'] = r['balance'] - r['credit'] = 0.0 - elif r['balance'] < 0: - r['debit'] = 0.0 - r['credit'] = -r['balance'] - else: - r['debit'] = 0.0 - r['credit'] = 0.0 - return res - - def _account_sum_debit(self, account_id, date1, date2): - self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id=%s AND date>=%s AND date<=%s AND amount>0", (account_id, date1, date2)) - return self.cr.fetchone()[0] or 0.0 - - def _account_sum_credit(self, account_id, date1, date2): - self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id=%s AND date>=%s AND date<=%s AND amount<0", (account_id, date1, date2)) - return self.cr.fetchone()[0] or 0.0 - - def _account_sum_balance(self, account_id, date1, date2): - debit = self._account_sum_debit(account_id, date1, date2) - credit = self._account_sum_credit(account_id, date1, date2) - return (debit-credit) - - def _account_sum_qty(self, account_id, date1, date2): - self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line WHERE account_id=%s AND date>=%s AND date<=%s", (account_id, date1, date2)) - return self.cr.fetchone()[0] or 0.0 - - def _account_sum_revenue(self, account_id): - return self.sum_revenue.get(account_id, 0.0) - - def _account_g_sum_revenue(self, general_account_id): - return self.account_sum_revenue.get(general_account_id, 0.0) - - def _sum_debit(self, accounts, date1, date2): - ids = map(lambda x: x.id, accounts) - if not ids: - return 0.0 - self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", (ids,date1, date2)) - return self.cr.fetchone()[0] or 0.0 - - def _sum_credit(self, accounts, date1, date2): - ids = map(lambda x: x.id, accounts) - if not ids: - return 0.0 - ids = map(lambda x: x.id, accounts) - self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", (ids, date1, date2)) - return self.cr.fetchone()[0] or 0.0 - - def _sum_balance(self, accounts, date1, date2): - debit = self._sum_debit(accounts, date1, date2) or 0.0 - credit = self._sum_credit(accounts, date1, date2) or 0.0 - return (debit-credit) - - def _sum_qty(self, accounts, date1, date2): - ids = map(lambda x: x.id, accounts) - if not ids: - return 0.0 - ids = map(lambda x: x.id, accounts) - self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line WHERE account_id =ANY(%s) AND date>=%s AND date<=%s", (ids,date1, date2)) - return self.cr.fetchone()[0] or 0.0 - - def _sum_revenue(self, accounts): - ids = map(lambda x: x.id, accounts) - if not ids: - return 0.0 - res = 0.0 - for id in ids: - res += self.sum_revenue.get(id, 0.0) - return res - -report_sxw.report_sxw( - 'report.hr.timesheet.invoice.account.analytic.account.cost_ledger', - 'account.analytic.account', - 'addons/hr_timesheet_invoice/report/cost_ledger.rml', - parser=account_analytic_cost_ledger, header='internal') - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/hr_timesheet_invoice/report/cost_ledger.rml b/addons/hr_timesheet_invoice/report/cost_ledger.rml deleted file mode 100644 index d014dd49927..00000000000 --- a/addons/hr_timesheet_invoice/report/cost_ledger.rml +++ /dev/null @@ -1,404 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [[ company.name ]] - - - Cost Ledger - - - - - - - - - - - - - - - - - - - - - Period from startdate - - - Period to enddate - - - Currency - - - Printing date - - - - - - - [[ data['form']['date1'] ]] - - - [[ data['form']['date2'] ]] - - - [[ company.currency_id.name ]] - - - [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]] - - - - - - - - - - - - - Date - - - J.C. - - - Code - - - Move name - - - Debit - - - Credit - - - Balance - - - - - - - [[ repeatIn(objects,'o') ]] -
- - - - [[ o.code ]] [[ o.complete_name ]] - - - - - - -
- - - - [[ repeatIn(lines_g(o.id,data['form']['date1'],data['form']['date2']),'move_g') ]] - - - - [[ move_g['code'] ]] [[ move_g['name'] ]] - - - - - - - [[ repeatIn(lines_a(move_g['id'],o.id,data['form']['date1'],data['form']['date2']),'move_a') ]] - [[ move_a['date'] ]] - - - [[ move_a['cj'] ]] - - - [[ move_a['code'] ]] - - - [[ move_a['name'] ]] - - - [[ '%.2f' % move_a['debit'] ]] - - - [[ '%.2f' % move_a['credit'] ]] - - - [[ '%.2f' % move_a['balance'] ]] - - - - - - - - - - Total ([[ move_g['code'] ]]) - - - [[ '%.2f' % move_g['debit'] ]] - - - [[ '%.2f' % move_g['credit'] ]] - - - [[ '%.2f' % move_g['balance'] ]] - - - - - - -
- - - - Total ([[ o.code ]]) - - - [[ '%.2f' % (account_sum_debit(o.id,data['form']['date1'],data['form']['date2']) or 0.0) ]] - - - [[ '%.2f' % (account_sum_credit(o.id,data['form']['date1'],data['form']['date2']) or 0.0) ]] - - - [[ '%.2f' % (account_sum_balance(o.id,data['form']['date1'],data['form']['date2']) or 0.0)]] - - - -
- - - - Total - - - [[ '%.2f' % (sum_debit(objects,data['form']['date1'],data['form']['date2']) or 0.0) ]] - - - [[ '%.2f' % (sum_credit(objects,data['form']['date1'],data['form']['date2']) or 0.0) ]] - - - [[ '%.2f' % (sum_balance(objects,data['form']['date1'],data['form']['date2']) or 0.0) ]] - - - - - - -
-
\ No newline at end of file diff --git a/addons/hr_timesheet_invoice/test/hr_timesheet_invoice_report.yml b/addons/hr_timesheet_invoice/test/hr_timesheet_invoice_report.yml index 2340d18e3f8..adce0e97fa3 100644 --- a/addons/hr_timesheet_invoice/test/hr_timesheet_invoice_report.yml +++ b/addons/hr_timesheet_invoice/test/hr_timesheet_invoice_report.yml @@ -7,14 +7,3 @@ (data, format) = netsvc.LocalService('report.account.analytic.profit').create(cr, uid, [], data_dict, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'hr_timesheet_invoice-account_analytic_profit_report.'+format), 'wb+').write(data) -- - Print the HR Cost Ledger report through the wizard -- - !python {model: account.analytic.account}: | - import netsvc, tools, os, time - ctx={} - acc_ids = [ref('account.analytic_absences'),ref('account.analytic_internal'),ref('account.analytic_sednacom'),ref('account.analytic_thymbra'),ref('account.analytic_partners_camp_to_camp')] - ctx.update({'model': 'ir.ui.menu','active_ids': acc_ids}) - data_dict = {'date1': time.strftime('%Y-01-01'), 'date2': time.strftime('%Y-%m-%d')} - from tools import test_reports - test_reports.try_report_action(cr, uid, 'action_hr_timesheet_invoice_cost_ledger',wiz_data=data_dict, context=ctx, our_module='hr_timesheet_invoice') diff --git a/addons/hr_timesheet_invoice/wizard/__init__.py b/addons/hr_timesheet_invoice/wizard/__init__.py index 6dce6a7b651..b718be1acbb 100644 --- a/addons/hr_timesheet_invoice/wizard/__init__.py +++ b/addons/hr_timesheet_invoice/wizard/__init__.py @@ -22,7 +22,6 @@ import hr_timesheet_invoice_create import hr_timesheet_analytic_profit import hr_timesheet_final_invoice_create -import hr_timesheet_analytic_cost_ledger_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_analytic_cost_ledger_report.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_analytic_cost_ledger_report.py deleted file mode 100644 index 892c93252ee..00000000000 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_analytic_cost_ledger_report.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## -import time - -from osv import osv, fields - -class hr_timesheet_analytic_cost_ledger(osv.osv_memory): - _name = 'hr.timesheet.analytic.cost.ledger' - _description = 'hr.timesheet.analytic.cost.ledger' - _columns = { - 'date1': fields.date('Start of period', required=True), - 'date2': fields.date('End of period', required=True) - } - _defaults = { - 'date1': lambda *a: time.strftime('%Y-01-01'), - 'date2': lambda *a: time.strftime('%Y-%m-%d') - } - def print_report(self, cr, uid, ids, context=None): - if context is None: - context = {} - datas = { - 'ids': 'active_ids' in context and context['active_ids'] or [], - 'model': 'account.analytic.account', - 'form': self.read(cr, uid, ids, context=context)[0] - } - return { - 'type': 'ir.actions.report.xml', - 'report_name': 'hr.timesheet.invoice.account.analytic.account.cost_ledger', - 'datas': datas, - } - -hr_timesheet_analytic_cost_ledger() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_analytic_cost_ledger_view.xml b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_analytic_cost_ledger_view.xml deleted file mode 100644 index 71706d9cdfe..00000000000 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_analytic_cost_ledger_view.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - Cost Ledger - hr.timesheet.analytic.cost.ledger - form - -
- - - - - - -