Merge lp:~acysos-team/openerp-spain/openerp-spain-fix-odoo into lp:~openerp-spain-team/openerp-spain/7.0

Proposed by Ignacio Ibeas (www.acysos.com)
Status: Merged
Merged at revision: 481
Proposed branch: lp:~acysos-team/openerp-spain/openerp-spain-fix-odoo
Merge into: lp:~openerp-spain-team/openerp-spain/7.0
Diff against target: 213 lines (+47/-69)
3 files modified
.directory (+0/-5)
l10n_es_aeat_mod340/account.py (+46/-63)
l10n_es_payment_order/report/remesas_report.py (+1/-1)
To merge this branch: bzr merge lp:~acysos-team/openerp-spain/openerp-spain-fix-odoo
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza code review Approve
Alejandro Santana code review, no test Approve
Review via email: mp+224448@code.launchpad.net

Description of the change

Adaptación de Mod340 y Payment_Order para hacerlos compatibles con Odoo.

To post a comment you must log in.
Revision history for this message
Alejandro Santana (alejandrosantana) :
review: Approve (code review, no test)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

LGTM.

Hay algunas cosas que corregir para cumplir con PEP8 y con las convenciones de comunidad, pero eso se puede hacer en otro momento.

Un saludo.

review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file '.directory'
2--- .directory 2012-11-15 16:14:59 +0000
3+++ .directory 1970-01-01 00:00:00 +0000
4@@ -1,5 +0,0 @@
5-[Dolphin]
6-Timestamp=2012,9,6,18,38,0
7-
8-[Settings]
9-HiddenFilesShown=true
10
11=== modified file 'l10n_es_aeat_mod340/account.py'
12--- l10n_es_aeat_mod340/account.py 2014-02-09 16:33:45 +0000
13+++ l10n_es_aeat_mod340/account.py 2014-06-25 13:31:44 +0000
14@@ -41,50 +41,50 @@
15 class wizard_update_charts_accounts(orm.TransientModel):
16 _inherit = 'wizard.update.charts.accounts'
17
18- def _find_tax_codes(self, cr, uid, wizard, context=None):
19+ def _find_tax_codes(self, cr, uid, wizard, chart_template_ids,
20+ context=None):
21 """
22 Search for, and load, tax code templates to create/update.
23+
24+ @param chart_template_ids: IDs of the chart templates to look on,
25+ calculated once in the calling method.
26 """
27+ if not wizard.chart_template_id:
28+ return {}
29 new_tax_codes = 0
30 updated_tax_codes = 0
31 tax_code_template_mapping = {}
32-
33- tax_code_templ_obj = self.pool.get('account.tax.code.template')
34- tax_code_obj = self.pool.get('account.tax.code')
35- wiz_tax_code_obj = self.pool.get('wizard.update.charts.accounts.tax.code')
36-
37+ tax_code_templ_obj = self.pool['account.tax.code.template']
38+ tax_code_obj = self.pool['account.tax.code']
39+ wiz_tax_code_obj = self.pool['wizard.update.charts.accounts.tax.code']
40 # Remove previous tax codes
41 wiz_tax_code_obj.unlink(cr, uid, wiz_tax_code_obj.search(cr, uid, []))
42-
43- #
44 # Search for new / updated tax codes
45- #
46 root_tax_code_id = wizard.chart_template_id.tax_code_root_id.id
47- children_tax_code_template = tax_code_templ_obj.search(cr, uid,
48- [('parent_id', 'child_of', [root_tax_code_id])], order='id')
49- for tax_code_template in tax_code_templ_obj.browse(cr, uid,
50- children_tax_code_template):
51- # Ensure the tax code template is on the map (search for the mapped tax code id).
52- self._map_tax_code_template(cr, uid, wizard,
53- tax_code_template_mapping,
54- tax_code_template, context)
55-
56- tax_code_id = tax_code_template_mapping.get(tax_code_template.id)
57+ children_tax_code_template = tax_code_templ_obj.search(cr, uid, [(
58+ 'parent_id', 'child_of', [root_tax_code_id])], order='id',
59+ context=context)
60+ for tax_code_template in tax_code_templ_obj.browse(cr, uid,
61+ children_tax_code_template, context=context):
62+ # Ensure the tax code template is on the map (search for the mapped
63+ # tax code id).
64+ tax_code_id = self._map_tax_code_template(cr, uid, wizard,
65+ tax_code_template_mapping,
66+ tax_code_template, context=context)
67 if not tax_code_id:
68 new_tax_codes += 1
69 wiz_tax_code_obj.create(cr, uid, {
70- 'tax_code_id': tax_code_template.id,
71- 'update_chart_wizard_id': wizard.id,
72- 'type': 'new',
73- }, context)
74+ 'tax_code_id': tax_code_template.id,
75+ 'update_chart_wizard_id': wizard.id,
76+ 'type': 'new',
77+ 'notes': _('Name or code not found.'),
78+ }, context)
79 elif wizard.update_tax_code:
80- #
81 # Check the tax code for changes.
82- #
83 modified = False
84 notes = ""
85- tax_code = tax_code_obj.browse(cr, uid, tax_code_id, context=context)
86-
87+ tax_code = tax_code_obj.browse(
88+ cr, uid, tax_code_id, context=context)
89 if tax_code.code != tax_code_template.code:
90 notes += _("The code field is different.\n")
91 modified = True
92@@ -97,49 +97,41 @@
93 if tax_code.mod340 != tax_code_template.mod340:
94 notes += _("The Mod 340 field is different.\n")
95 modified = True
96-
97 # TODO: We could check other account fields for changes...
98-
99 if modified:
100- #
101 # Tax code to update.
102- #
103 updated_tax_codes += 1
104 wiz_tax_code_obj.create(cr, uid, {
105- 'tax_code_id': tax_code_template.id,
106- 'update_chart_wizard_id': wizard.id,
107- 'type': 'updated',
108- 'update_tax_code_id': tax_code_id,
109- 'notes': notes,
110- }, context)
111-
112- return { 'new': new_tax_codes, 'updated': updated_tax_codes,
113- 'mapping': tax_code_template_mapping }
114+ 'tax_code_id': tax_code_template.id,
115+ 'update_chart_wizard_id': wizard.id,
116+ 'type': 'updated',
117+ 'update_tax_code_id': tax_code_id,
118+ 'notes': notes,
119+ }, context)
120+ return {
121+ 'new': new_tax_codes,
122+ 'updated': updated_tax_codes,
123+ 'mapping': tax_code_template_mapping
124+ }
125
126 def _update_tax_codes(self, cr, uid, wizard, log, context=None):
127 """
128 Search for, and load, tax code templates to create/update.
129 """
130- tax_code_obj = self.pool.get('account.tax.code')
131-
132+ taxcodes = self.pool.get('account.tax.code')
133 root_tax_code_id = wizard.chart_template_id.tax_code_root_id.id
134-
135 new_tax_codes = 0
136 updated_tax_codes = 0
137 tax_code_template_mapping = {}
138-
139 for wiz_tax_code in wizard.tax_code_ids:
140 tax_code_template = wiz_tax_code.tax_code_id
141 tax_code_name = (root_tax_code_id == tax_code_template.id) and wizard.company_id.name or tax_code_template.name
142-
143 # Ensure the parent tax code template is on the map.
144- self._map_tax_code_template(cr, uid, wizard,
145- tax_code_template_mapping,
146- tax_code_template.parent_id, context)
147-
148- #
149+ self._map_tax_code_template(cr, uid, wizard,
150+ tax_code_template_mapping,
151+ tax_code_template.parent_id,
152+ context=context)
153 # Values
154- #
155 vals = {
156 'name': tax_code_name,
157 'code': tax_code_template.code,
158@@ -152,40 +144,31 @@
159
160 tax_code_id = None
161 modified = False
162-
163 if wiz_tax_code.type == 'new':
164- #
165 # Create the tax code
166- #
167- tax_code_id = tax_code_obj.create(cr, uid, vals)
168+ tax_code_id = taxcodes.create(cr, uid, vals)
169 log.add(_("Created tax code %s.\n") % tax_code_name)
170 new_tax_codes += 1
171 modified = True
172 elif wizard.update_tax_code and wiz_tax_code.update_tax_code_id:
173- #
174 # Update the tax code
175- #
176 tax_code_id = wiz_tax_code.update_tax_code_id.id
177- tax_code_obj.write(cr, uid, [tax_code_id], vals)
178+ taxcodes.write(cr, uid, [tax_code_id], vals)
179 log.add(_("Updated tax code %s.\n") % tax_code_name)
180 updated_tax_codes += 1
181 modified = True
182 else:
183 tax_code_id = wiz_tax_code.update_tax_code_id and wiz_tax_code.update_tax_code_id.id
184 modified = False
185-
186 # Store the tax codes on the map
187 tax_code_template_mapping[tax_code_template.id] = tax_code_id
188-
189 if modified:
190- #
191 # Detect errors
192- #
193 if tax_code_template.parent_id and not tax_code_template_mapping.get(tax_code_template.parent_id.id):
194 log.add(_("Tax code %s: The parent tax code %s can not be set.\n") % (tax_code_name, tax_code_template.parent_id.name), True)
195-
196 return {
197 'new': new_tax_codes,
198 'updated': updated_tax_codes,
199 'mapping': tax_code_template_mapping
200 }
201+
202
203=== modified file 'l10n_es_payment_order/report/remesas_report.py'
204--- l10n_es_payment_order/report/remesas_report.py 2011-08-29 15:11:11 +0000
205+++ l10n_es_payment_order/report/remesas_report.py 2014-06-25 13:31:44 +0000
206@@ -22,7 +22,7 @@
207 ##############################################################################
208
209 import time
210-from report import report_sxw
211+from openerp.report import report_sxw
212
213 class remesas_report(report_sxw.rml_parse):
214