Merge lp:~therp-nl/neobis-addons/6.1-auditfile_fixes into lp:neobis-addons/6.1

Proposed by Holger Brunn (Therp) on 2014-01-27
Status: Merged
Approved by: Elias on 2014-01-28
Approved revision: 5
Merged at revision: 5
Proposed branch: lp:~therp-nl/neobis-addons/6.1-auditfile_fixes
Merge into: lp:neobis-addons/6.1
Diff against target: 111 lines (+22/-18)
2 files modified
nbs_xml_auditfile_financieel/auditfile_export.py (+14/-11)
nbs_xml_auditfile_financieel/data/auditfile_template.xml (+8/-7)
To merge this branch: bzr merge lp:~therp-nl/neobis-addons/6.1-auditfile_fixes
Reviewer Review Type Date Requested Status
Elias visual 2014-01-27 Approve on 2014-01-28
Review via email: mp+203371@code.launchpad.net

Description of the change

Thanks for the auditfile module!

This MP mainly contains fixes for coping with malformatted in the database and changes the way parters are selected, as the original way of doing it goes wrong for very big databases with a lot of partners.

To post a comment you must log in.
Elias (rtxehi) wrote :

Holger,

Thanks for the updates, they look good to me, so I'll merge the changes soon.

Thanks again!

review: Approve (visual)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nbs_xml_auditfile_financieel/auditfile_export.py'
2--- nbs_xml_auditfile_financieel/auditfile_export.py 2013-03-25 13:47:29 +0000
3+++ nbs_xml_auditfile_financieel/auditfile_export.py 2014-01-27 16:46:34 +0000
4@@ -26,6 +26,7 @@
5 from tools.translate import _
6 from lxml import etree
7 import sys
8+import traceback
9 import release
10 import datetime
11 import logging
12@@ -89,11 +90,20 @@
13
14 data = self.browse(cr, uid, ids[0], context=id)
15
16+ # periods search
17+ period_obj = self.pool.get("account.period")
18+ period_ids = period_obj.search(cr, uid, ['&',
19+ ('id', '>=', data.period_start.id),
20+ ('id', '<=', data.period_stop.id)])
21+ periods = period_obj.browse(cr, uid, period_ids)
22+
23 # partners search
24+ cr.execute(
25+ 'select distinct partner_id from account_move_line where '
26+ 'period_id in %s and partner_id is not NULL',
27+ (tuple(period_ids),))
28+ partners_obj_ids = [x[0] or 0 for x in cr.fetchall()]
29 partners_obj = self.pool.get("res.partner")
30- partners_obj_ids = partners_obj.search(cr, uid, ['|',
31- ('supplier', '=', 'True'),
32- ('customer', '=', 'True')])
33 partners = partners_obj.browse(cr, uid, partners_obj_ids)
34
35 if not partners:
36@@ -116,13 +126,6 @@
37 return True
38 _validate_country_ids(partners)
39
40- # periods search
41- period_obj = self.pool.get("account.period")
42- period_ids = period_obj.search(cr, uid, ['&',
43- ('id', '>=', data.period_start.id),
44- ('id', '<=', data.period_stop.id)])
45- periods = period_obj.browse(cr, uid, period_ids)
46-
47 # journal search
48 journal_obj = self.pool.get("account.journal")
49 journal_ids = journal_obj.search(cr, uid, [])
50@@ -253,7 +256,7 @@
51 )
52 self._logger.info('auditfile_export created succesfully')
53 except:
54- self._logger.error(sys.exc_info())
55+ self._logger.error(traceback.format_exception(*sys.exc_info()))
56 raise osv.except_osv(_('Data Error'),
57 _('Invalid Data. Please, see logs for details.'))
58
59
60=== modified file 'nbs_xml_auditfile_financieel/data/auditfile_template.xml'
61--- nbs_xml_auditfile_financieel/data/auditfile_template.xml 2013-03-25 13:47:29 +0000
62+++ nbs_xml_auditfile_financieel/data/auditfile_template.xml 2014-01-27 16:46:34 +0000
63@@ -16,40 +16,41 @@
64 <p:streetAddress>
65 <p:streetname text-eval="text(company.street)"></p:streetname>
66 <p:city text-eval="text(company.city)"></p:city>
67- <p:postalCode text-eval="text(company.zip)"></p:postalCode>
68+ <p:postalCode text-eval="text(company.zip)[:10]"></p:postalCode>
69 <p:region text-eval="text(company.state_id.name)"></p:region>
70 <p:country text-eval="company.country_id.code"></p:country>
71 </p:streetAddress>
72 <p:postalAddress>
73 <p:streetname text-eval="text(company.street)"></p:streetname>
74 <p:city text-eval="text(company.city)"></p:city>
75- <p:postalCode text-eval="text(company.zip)"></p:postalCode>
76+ <p:postalCode text-eval="text(company.zip)[:10]"></p:postalCode>
77 <p:region text-eval="text(company.state_id.name)"></p:region>
78 <p:country text-eval="company.country_id.code"></p:country>
79 </p:postalAddress>
80 <p:customersSuppliers>
81+ <p:customerSupplier><p:custSupID text-eval="'False'"></p:custSupID></p:customerSupplier>
82 <p:customerSupplier seq-eval="partners" var="partner">
83 <p:custSupID text-eval="partner.id"></p:custSupID>
84- <p:custSupName text-eval="partner.name"></p:custSupName>
85- <p:contact text-eval="partner.name"></p:contact>
86+ <p:custSupName text-eval="partner.name[:50]"></p:custSupName>
87+ <p:contact text-eval="partner.name[:50]"></p:contact>
88 <p:telephone text-eval="text(partner.phone)"></p:telephone>
89 <p:fax text-eval="text(partner.phone)"></p:fax>
90 <p:eMail text-eval="text(partner.email)"></p:eMail>
91 <p:website text-eval="text(partner.website)"></p:website>
92- <p:taxRegistrationCountry text-eval="partner.address[0].country_id.code"></p:taxRegistrationCountry>
93+ <p:taxRegistrationCountry text-eval="partner.address and partner.address[0].country_id.code"></p:taxRegistrationCountry>
94 <p:taxRegIdent text-eval="text(partner.vat)"></p:taxRegIdent>
95 <p:custSupTp text-eval="custSupTp(partner.supplier,partner.customer)"></p:custSupTp>
96 <p:streetAddress seq-eval="partner.address" var="address">
97 <p:streetname text-eval="text(address.street)"></p:streetname>
98 <p:city text-eval="text(address.city)"></p:city>
99- <p:postalCode text-eval="text(address.zip)"></p:postalCode>
100+ <p:postalCode text-eval="text(address.zip)[:10]"></p:postalCode>
101 <p:region text-eval="text(address.state_id.name)"></p:region>
102 <p:country text-eval="address.country_id.code"></p:country>
103 </p:streetAddress>
104 <p:postalAddress seq-eval="partner.address" var="address">
105 <p:streetname text-eval="text(address.street)"></p:streetname>
106 <p:city text-eval="text(address.city)"></p:city>
107- <p:postalCode text-eval="text(address.zip)"></p:postalCode>
108+ <p:postalCode text-eval="text(address.zip)[:10]"></p:postalCode>
109 <p:region text-eval="text(address.state_id.name)"></p:region>
110 <p:country text-eval="address.country_id.code"></p:country>
111 </p:postalAddress>

Subscribers

People subscribed via source and target branches