Merge lp:~bruno-bottacini/account-financial-tools/7.0-fix_account_move_template into lp:~account-core-editors/account-financial-tools/7.0

Proposed by bruno bottacini
Status: Merged
Merged at revision: 114
Proposed branch: lp:~bruno-bottacini/account-financial-tools/7.0-fix_account_move_template
Merge into: lp:~account-core-editors/account-financial-tools/7.0
Diff against target: 302 lines (+37/-44)
6 files modified
account_move_template/__openerp__.py (+4/-6)
account_move_template/account_document_template.py (+6/-10)
account_move_template/account_move_template.py (+3/-7)
account_move_template/move_template.xml (+1/-6)
account_move_template/wizard/select_template.py (+23/-12)
account_move_template/wizard/select_template.xml (+0/-3)
To merge this branch: bzr merge lp:~bruno-bottacini/account-financial-tools/7.0-fix_account_move_template
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp code review, no test Approve
Lorenzo Battistini (community) code review Approve
Stefan Rijnhart (Opener) Approve
Review via email: mp+169758@code.launchpad.net

Description of the change

account_move_template migration to openerp 7.0

To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks for following up my suggestions from the other proposal!

Next time, you do not have to delete the earlier proposal but you can instead simply add such changes in an extra bzr commit on the same branch. When you repush the branch to launchpad, the MP will pick this up and reflect the additional changes in its diff. You can then reinvite the reviewers by entering a simple comment on the proposal, or more formally click the 'resubmit proposal' link at the top of the proposal screen in Launchpad.

review: Approve
Revision history for this message
Lorenzo Battistini (elbati) :
review: Approve (code review)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Thanks!
LGTM

review: Approve (code review, no test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_move_template/__openerp__.py'
2--- account_move_template/__openerp__.py 2013-01-15 19:02:11 +0000
3+++ account_move_template/__openerp__.py 2013-06-17 10:32:31 +0000
4@@ -32,17 +32,15 @@
5 'author': 'Agile Business Group',
6 'website': 'http://www.agilebg.com',
7 'license': 'AGPL-3',
8- "depends" : ['account_accountant', 'analytic'],
9- "init_xml" : [],
10- "update_xml" : [
11+ 'depends' : ['account_accountant', 'analytic'],
12+ 'data' : [
13 'move_template.xml',
14 'wizard/select_template.xml',
15 'security/ir.model.access.csv',
16 ],
17- "demo_xml" : [],
18 'test': [
19 'test/generate_move.yml',
20 ],
21- "active": False,
22- "installable": True
23+ 'active': False,
24+ 'installable': True,
25 }
26
27=== modified file 'account_move_template/account_document_template.py'
28--- account_move_template/account_document_template.py 2013-01-04 13:48:18 +0000
29+++ account_move_template/account_document_template.py 2013-06-17 10:32:31 +0000
30@@ -19,11 +19,11 @@
31 #
32 ##############################################################################
33
34-from openerp.osv import fields, osv
35+from openerp.osv import fields, orm
36 from openerp.tools.translate import _
37 import re
38
39-class account_document_template(osv.osv):
40+class account_document_template(orm.Model):
41
42 _computed_lines = {}
43 _current_template_id = 0
44@@ -59,12 +59,12 @@
45 return self._computed_lines[line_number]
46 line = self._get_template_line(self._cr, self._uid, self._current_template_id, line_number)
47 if re.match('L\( *'+str(line_number)+' *\)',line.python_code):
48- raise osv.except_osv(_('Error'),
49+ raise orm.except_orm(_('Error'),
50 _('Line %s can\'t refer to itself') % str(line_number))
51 try:
52 self._computed_lines[line_number] = eval(line.python_code.replace('L', 'self.lines'))
53 except KeyError:
54- raise osv.except_osv(_('Error'),
55+ raise orm.except_orm(_('Error'),
56 _('Code "%s" refers to non existing line') % line.python_code)
57 return self._computed_lines[line_number]
58
59@@ -73,7 +73,7 @@
60 # returns all the lines (included input lines) in the form {line_number: line_amount}
61 template = self.browse(cr, uid, template_id)
62 if len(input_lines) != self._input_lines(cr, uid, template):
63- raise osv.except_osv(_('Error'),
64+ raise orm.except_orm(_('Error'),
65 _('Inconsistency between input lines and filled lines for template %s') % template.name)
66 self._current_template_id = template.id
67 self._cr = cr
68@@ -92,9 +92,7 @@
69 return True
70 return False
71
72-account_document_template()
73-
74-class account_document_template_line(osv.osv):
75+class account_document_template_line(orm.Model):
76
77 _name = 'account.document.template.line'
78
79@@ -104,5 +102,3 @@
80 'type': fields.selection([('computed', 'Computed'),('input', 'User input')], 'Type', required=True),
81 'python_code':fields.text('Python Code'),
82 }
83-
84-account_document_template_line()
85
86=== modified file 'account_move_template/account_move_template.py'
87--- account_move_template/account_move_template.py 2013-01-04 13:48:18 +0000
88+++ account_move_template/account_move_template.py 2013-06-17 10:32:31 +0000
89@@ -19,10 +19,10 @@
90 #
91 ##############################################################################
92
93-from openerp.osv import fields, osv
94+from openerp.osv import fields, orm
95 from openerp.tools.translate import _
96
97-class account_move_template(osv.osv):
98+class account_move_template(orm.Model):
99
100 _inherit = 'account.document.template'
101 _name = 'account.move.template'
102@@ -58,10 +58,8 @@
103 'If the template is "cross-journals", the Journals must be different,' \
104 'if the template does not "cross-journals" the Journals must be the same!',
105 ['journal_id'])]
106-
107-account_move_template()
108
109-class account_move_template_line(osv.osv):
110+class account_move_template_line(orm.Model):
111
112 _name = 'account.move.template.line'
113 _inherit = 'account.document.template.line'
114@@ -81,5 +79,3 @@
115 _sql_constraints = [
116 ('sequence_template_uniq', 'unique (template_id,sequence)', 'The sequence of the line must be unique per template !')
117 ]
118-
119-account_move_template_line()
120
121=== modified file 'account_move_template/move_template.xml'
122--- account_move_template/move_template.xml 2012-11-16 23:44:13 +0000
123+++ account_move_template/move_template.xml 2013-06-17 10:32:31 +0000
124@@ -5,7 +5,6 @@
125 <record id="view_move_template_line_tree" model="ir.ui.view">
126 <field name="name">account.move.template.line.tree</field>
127 <field name="model">account.move.template.line</field>
128- <field name="type">tree</field>
129 <field name="arch" type="xml">
130 <tree string="Journal Entry Template Line">
131 <field name="sequence"/>
132@@ -25,7 +24,6 @@
133 <record id="view_move_template_line_form" model="ir.ui.view">
134 <field name="name">account.move.template.line.form</field>
135 <field name="model">account.move.template.line</field>
136- <field name="type">form</field>
137 <field name="arch" type="xml">
138 <form string="Journal Entry Template Line">
139 <field colspan="4" name="name" select="1"/>
140@@ -46,7 +44,6 @@
141 <record id="view_move_template_form" model="ir.ui.view">
142 <field name="name">account.move.template.form</field>
143 <field name="model">account.move.template</field>
144- <field name="type">form</field>
145 <field name="arch" type="xml">
146 <form string="Journal Entry Template">
147 <field name="name"/>
148@@ -61,7 +58,6 @@
149 <record id="view_move_template_tree" model="ir.ui.view">
150 <field name="name">account.move.template.tree</field>
151 <field name="model">account.move.template</field>
152- <field name="type">tree</field>
153 <field name="arch" type="xml">
154 <tree string="Journal Entry Template">
155 <field name="name"/>
156@@ -73,7 +69,6 @@
157 <record id="view_move_template_search" model="ir.ui.view">
158 <field name="name">account.move.template.search</field>
159 <field name="model">account.move.template</field>
160- <field name="type">search</field>
161 <field name="arch" type="xml">
162 <search string="Journal Entry Template">
163 <group>
164@@ -94,6 +89,6 @@
165 </record>
166 <menuitem
167 action="action_move_template_form" id="menu_action_move_template_form" sequence="5"
168- parent="account.menu_configuration_misc" groups="base.group_extended"/>
169+ parent="account.menu_configuration_misc" groups="account.group_account_manager"/>
170 </data>
171 </openerp>
172
173=== modified file 'account_move_template/wizard/select_template.py'
174--- account_move_template/wizard/select_template.py 2013-01-04 13:48:18 +0000
175+++ account_move_template/wizard/select_template.py 2013-06-17 10:32:31 +0000
176@@ -19,11 +19,11 @@
177 #
178 ##############################################################################
179
180-from openerp.osv import fields,osv
181+from openerp.osv import fields,orm
182 import time
183 from openerp.tools.translate import _
184
185-class wizard_select_template(osv.osv_memory):
186+class wizard_select_template(orm.TransientModel):
187
188 _name = "wizard.select.move.template"
189 _columns = {
190@@ -55,6 +55,8 @@
191 wizard = self.browse(cr, uid, ids, context=context)[0]
192 template_pool = self.pool.get('account.move.template')
193 wizard_line_pool = self.pool.get('wizard.select.move.template.line')
194+ model_data_obj = self.pool.get('ir.model.data')
195+
196 template = template_pool.browse(cr, uid, wizard.template_id.id)
197 for line in template.template_line_ids:
198 if line.type == 'input':
199@@ -69,7 +71,20 @@
200 if not wizard.line_ids:
201 return self.load_template(cr, uid, ids)
202 wizard.write({'state': 'template_selected'})
203- return True
204+
205+ view_rec = model_data_obj.get_object_reference(cr, uid, 'account_move_template', 'wizard_select_template')
206+ view_id = view_rec and view_rec[1] or False
207+
208+ return {
209+ 'view_type': 'form',
210+ 'view_id' : [view_id],
211+ 'view_mode': 'form',
212+ 'res_model': 'wizard.select.move.template',
213+ 'res_id': wizard.id,
214+ 'type': 'ir.actions.act_window',
215+ 'target': 'new',
216+ 'context': context,
217+ }
218
219 def load_template(self, cr, uid, ids, context=None):
220 template_obj = self.pool.get('account.move.template')
221@@ -80,7 +95,7 @@
222 mod_obj = self.pool.get('ir.model.data')
223 wizard = self.browse(cr, uid, ids, context=context)[0]
224 if not template_obj.check_zero_lines(cr, uid, wizard):
225- raise osv.except_osv(_('Error !'), _('At least one amount has to be non-zero!'))
226+ raise orm.except_orm(_('Error !'), _('At least one amount has to be non-zero!'))
227 input_lines = {}
228
229 for template_line in wizard.line_ids:
230@@ -88,7 +103,7 @@
231
232 period_id = account_period_obj.find(cr, uid, context=context)
233 if not period_id:
234- raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
235+ raise orm.except_orm(_('No period found !'), _('Unable to find a valid period !'))
236 period_id = period_id[0]
237
238 computed_lines = template_obj.compute_lines(cr, uid, wizard.template_id.id, input_lines)
239@@ -131,7 +146,7 @@
240 analytic_account_id = False
241 if line.analytic_account_id:
242 if not line.journal_id.analytic_journal_id:
243- raise osv.except_osv(_('No Analytic Journal !'),
244+ raise orm.except_orm(_('No Analytic Journal !'),
245 _("You have to define an analytic journal on the '%s' journal!")
246 % (line.journal_id.name,))
247 analytic_account_id = line.analytic_account_id.id
248@@ -161,7 +176,7 @@
249 analytic_account_id = False
250 if line.analytic_account_id:
251 if not line.journal_id.analytic_journal_id:
252- raise osv.except_osv(_('No Analytic Journal !'),
253+ raise orm.except_orm(_('No Analytic Journal !'),
254 _("You have to define an analytic journal on the '%s' journal!")
255 % (wizard.template_id.journal_id.name,))
256 analytic_account_id = line.analytic_account_id.id
257@@ -181,10 +196,8 @@
258 val['debit'] = computed_lines[line.sequence]
259 id_line = account_move_line_obj.create(cr, uid, val)
260 return id_line
261-
262-wizard_select_template()
263
264-class wizard_select_template_line(osv.osv_memory):
265+class wizard_select_template_line(orm.TransientModel):
266 _description = 'Template Lines'
267 _name = "wizard.select.move.template.line"
268 _columns = {
269@@ -198,5 +211,3 @@
270 ], 'Move Line Type', required=True,readonly=True),
271 'amount': fields.float('Amount', required=True),
272 }
273-
274-wizard_select_template_line()
275
276=== modified file 'account_move_template/wizard/select_template.xml'
277--- account_move_template/wizard/select_template.xml 2012-11-16 23:44:13 +0000
278+++ account_move_template/wizard/select_template.xml 2013-06-17 10:32:31 +0000
279@@ -5,7 +5,6 @@
280 <record id="wizard_select_template" model="ir.ui.view">
281 <field name="name">Select Move Template</field>
282 <field name="model">wizard.select.move.template</field>
283- <field name="type">form</field>
284 <field name="arch" type="xml">
285 <form string="Move Template" >
286 <group col="2" width="600" height="500">
287@@ -29,7 +28,6 @@
288 <record id="wizard_select_template_line" model="ir.ui.view">
289 <field name="name">Select Move Template Line</field>
290 <field name="model">wizard.select.move.template.line</field>
291- <field name="type">form</field>
292 <field name="arch" type="xml">
293 <form string="Move Template Line">
294 <group col="2">
295@@ -46,7 +44,6 @@
296 <record id="wizard_select_template_line_tree" model="ir.ui.view">
297 <field name="name">Select Move Template Line</field>
298 <field name="model">wizard.select.move.template.line</field>
299- <field name="type">tree</field>
300 <field name="arch" type="xml">
301 <tree string="Move Template Line" editable="bottom">
302 <field name="sequence" invisible="1"/>

Subscribers

People subscribed via source and target branches