Merge lp:~xmo-deactivatedaccount/openobject-addons/fix-tax-code-report into lp:openobject-addons/5.0

Proposed by Xavier (Open ERP)
Status: Merged
Merged at revision: 2448
Proposed branch: lp:~xmo-deactivatedaccount/openobject-addons/fix-tax-code-report
Merge into: lp:openobject-addons/5.0
Diff against target: 74 lines (+29/-25)
1 file modified
account/report/account_tax_code.py (+29/-25)
To merge this branch: bzr merge lp:~xmo-deactivatedaccount/openobject-addons/fix-tax-code-report
Reviewer Review Type Date Requested Status
Husen Daudi (community) Approve
Review via email: mp+14993@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

Fixe un bug dans account/report/account_tax_code.py et clarifie un peu le code.

Revision history for this message
Husen Daudi (husendaudi) wrote :

Merged in revision : 2448 <email address hidden>
Thanks for contribution.

review: Approve
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

Welcome home Xavier :)

Xavier Morel wrote:
> Xavier Morel has proposed merging lp:~xmo/openobject-addons/fix-tax-code-report into lp:openobject-addons/5.0.
>
> Requested reviews:
> OpenERP Quality Team (openerp)
>
>
> Fixe un bug dans account/report/account_tax_code.py et clarifie un peu le code.
>

--
Fabien Pinckaers
CEO Tiny - OpenERP Editor
Chaussée de Namur 40
B-1367 Grand-Rosière
Belgium
Phone: +32.81.81.37.00
Fax: +32.81.73.35.01
Web: http://openerp.com

Great Achievements Start With Tiny Investments
  -- Marty, 2005

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/report/account_tax_code.py'
2--- account/report/account_tax_code.py 2009-10-09 11:49:00 +0000
3+++ account/report/account_tax_code.py 2009-11-18 13:35:28 +0000
4@@ -1,4 +1,5 @@
5-# -*- encoding: utf-8 -*-
6+#!/usr/bin/env python
7+# -*- coding: utf-8 -*-
8 ##############################################################################
9 #
10 # OpenERP, Open Source Management Solution
11@@ -26,6 +27,25 @@
12 from report import report_sxw
13 import re
14
15+def _get_country(record):
16+ if record.partner_id \
17+ and record.partner_id.address \
18+ and record.partner_id.address[0].country_id:
19+ return record.partner_id.address[0].country_id.code
20+ else:
21+ return ''
22+
23+def _record_to_report_line(record):
24+ return {'date': record.date,
25+ 'ref': record.ref,
26+ 'acode': record.account_id.code,
27+ 'name': record.name,
28+ 'debit': record.debit,
29+ 'credit': record.credit,
30+ 'pname': record.partner_id and record.partner_id.name or '',
31+ 'country': _get_country(record)
32+ }
33+
34 class account_tax_code_report(rml_parse.rml_parse):
35 #_name = 'report.account.tax.code.entries'
36
37@@ -36,30 +56,14 @@
38 'get_line':self.get_line,
39 })
40
41- def get_line(self,obj):
42- res = {}
43- result = []
44- line_ids = self.pool.get('account.move.line').search(self.cr,self.uid,[('tax_code_id','=',obj.id)])
45- if line_ids:
46- move_line_objs = self.pool.get('account.move.line').browse(self.cr,self.uid,line_ids)
47- for line in move_line_objs:
48- res['date'] = line.date
49- res['ref'] = line.ref
50- res['acode'] = line.account_id.code
51- res['pname'] = ''
52- res['country'] = ''
53-
54- if line.partner_id:
55- res['pname'] = line.partner_id.name
56- if line.partner_id.address and line.partner_id.address[0].country_id:
57- res['country'] = line.partner_id.address[0].country_id.code
58- res['name'] = line.name
59- res['debit'] = line.debit
60- res['credit'] = line.credit
61- result.append(res)
62-
63- return result
64-
65+ def get_line(self, obj):
66+ line_ids = self.pool.get('account.move.line').search(self.cr, self.uid, [('tax_code_id','=',obj.id)])
67+ if not line_ids: return []
68+
69+ return map(_record_to_report_line,
70+ self.pool.get('account.move.line')\
71+ .browse(self.cr, self.uid, line_ids))
72+
73 report_sxw.report_sxw('report.account.tax.code.entries', 'account.tax.code',
74 'addons/account/report/account_tax_code.rml', parser=account_tax_code_report, header=False)
75