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
=== modified file 'account_move_template/__openerp__.py'
--- account_move_template/__openerp__.py 2013-01-15 19:02:11 +0000
+++ account_move_template/__openerp__.py 2013-06-17 10:32:31 +0000
@@ -32,17 +32,15 @@
32 'author': 'Agile Business Group',32 'author': 'Agile Business Group',
33 'website': 'http://www.agilebg.com',33 'website': 'http://www.agilebg.com',
34 'license': 'AGPL-3',34 'license': 'AGPL-3',
35 "depends" : ['account_accountant', 'analytic'],35 'depends' : ['account_accountant', 'analytic'],
36 "init_xml" : [],36 'data' : [
37 "update_xml" : [
38 'move_template.xml',37 'move_template.xml',
39 'wizard/select_template.xml',38 'wizard/select_template.xml',
40 'security/ir.model.access.csv',39 'security/ir.model.access.csv',
41 ],40 ],
42 "demo_xml" : [],
43 'test': [41 'test': [
44 'test/generate_move.yml',42 'test/generate_move.yml',
45 ],43 ],
46 "active": False,44 'active': False,
47 "installable": True45 'installable': True,
48}46}
4947
=== modified file 'account_move_template/account_document_template.py'
--- account_move_template/account_document_template.py 2013-01-04 13:48:18 +0000
+++ account_move_template/account_document_template.py 2013-06-17 10:32:31 +0000
@@ -19,11 +19,11 @@
19#19#
20##############################################################################20##############################################################################
2121
22from openerp.osv import fields, osv22from openerp.osv import fields, orm
23from openerp.tools.translate import _23from openerp.tools.translate import _
24import re24import re
2525
26class account_document_template(osv.osv):26class account_document_template(orm.Model):
2727
28 _computed_lines = {}28 _computed_lines = {}
29 _current_template_id = 029 _current_template_id = 0
@@ -59,12 +59,12 @@
59 return self._computed_lines[line_number]59 return self._computed_lines[line_number]
60 line = self._get_template_line(self._cr, self._uid, self._current_template_id, line_number)60 line = self._get_template_line(self._cr, self._uid, self._current_template_id, line_number)
61 if re.match('L\( *'+str(line_number)+' *\)',line.python_code):61 if re.match('L\( *'+str(line_number)+' *\)',line.python_code):
62 raise osv.except_osv(_('Error'),62 raise orm.except_orm(_('Error'),
63 _('Line %s can\'t refer to itself') % str(line_number))63 _('Line %s can\'t refer to itself') % str(line_number))
64 try:64 try:
65 self._computed_lines[line_number] = eval(line.python_code.replace('L', 'self.lines'))65 self._computed_lines[line_number] = eval(line.python_code.replace('L', 'self.lines'))
66 except KeyError:66 except KeyError:
67 raise osv.except_osv(_('Error'),67 raise orm.except_orm(_('Error'),
68 _('Code "%s" refers to non existing line') % line.python_code)68 _('Code "%s" refers to non existing line') % line.python_code)
69 return self._computed_lines[line_number]69 return self._computed_lines[line_number]
7070
@@ -73,7 +73,7 @@
73 # returns all the lines (included input lines) in the form {line_number: line_amount}73 # returns all the lines (included input lines) in the form {line_number: line_amount}
74 template = self.browse(cr, uid, template_id)74 template = self.browse(cr, uid, template_id)
75 if len(input_lines) != self._input_lines(cr, uid, template):75 if len(input_lines) != self._input_lines(cr, uid, template):
76 raise osv.except_osv(_('Error'),76 raise orm.except_orm(_('Error'),
77 _('Inconsistency between input lines and filled lines for template %s') % template.name)77 _('Inconsistency between input lines and filled lines for template %s') % template.name)
78 self._current_template_id = template.id78 self._current_template_id = template.id
79 self._cr = cr79 self._cr = cr
@@ -92,9 +92,7 @@
92 return True92 return True
93 return False93 return False
9494
95account_document_template()95class account_document_template_line(orm.Model):
96
97class account_document_template_line(osv.osv):
9896
99 _name = 'account.document.template.line'97 _name = 'account.document.template.line'
10098
@@ -104,5 +102,3 @@
104 'type': fields.selection([('computed', 'Computed'),('input', 'User input')], 'Type', required=True),102 'type': fields.selection([('computed', 'Computed'),('input', 'User input')], 'Type', required=True),
105 'python_code':fields.text('Python Code'),103 'python_code':fields.text('Python Code'),
106 }104 }
107
108account_document_template_line()
109105
=== modified file 'account_move_template/account_move_template.py'
--- account_move_template/account_move_template.py 2013-01-04 13:48:18 +0000
+++ account_move_template/account_move_template.py 2013-06-17 10:32:31 +0000
@@ -19,10 +19,10 @@
19#19#
20##############################################################################20##############################################################################
2121
22from openerp.osv import fields, osv22from openerp.osv import fields, orm
23from openerp.tools.translate import _23from openerp.tools.translate import _
2424
25class account_move_template(osv.osv):25class account_move_template(orm.Model):
2626
27 _inherit = 'account.document.template'27 _inherit = 'account.document.template'
28 _name = 'account.move.template'28 _name = 'account.move.template'
@@ -58,10 +58,8 @@
58 'If the template is "cross-journals", the Journals must be different,' \58 'If the template is "cross-journals", the Journals must be different,' \
59 'if the template does not "cross-journals" the Journals must be the same!',59 'if the template does not "cross-journals" the Journals must be the same!',
60 ['journal_id'])]60 ['journal_id'])]
61
62account_move_template()
6361
64class account_move_template_line(osv.osv):62class account_move_template_line(orm.Model):
6563
66 _name = 'account.move.template.line'64 _name = 'account.move.template.line'
67 _inherit = 'account.document.template.line'65 _inherit = 'account.document.template.line'
@@ -81,5 +79,3 @@
81 _sql_constraints = [79 _sql_constraints = [
82 ('sequence_template_uniq', 'unique (template_id,sequence)', 'The sequence of the line must be unique per template !')80 ('sequence_template_uniq', 'unique (template_id,sequence)', 'The sequence of the line must be unique per template !')
83 ]81 ]
84
85account_move_template_line()
8682
=== modified file 'account_move_template/move_template.xml'
--- account_move_template/move_template.xml 2012-11-16 23:44:13 +0000
+++ account_move_template/move_template.xml 2013-06-17 10:32:31 +0000
@@ -5,7 +5,6 @@
5 <record id="view_move_template_line_tree" model="ir.ui.view">5 <record id="view_move_template_line_tree" model="ir.ui.view">
6 <field name="name">account.move.template.line.tree</field>6 <field name="name">account.move.template.line.tree</field>
7 <field name="model">account.move.template.line</field>7 <field name="model">account.move.template.line</field>
8 <field name="type">tree</field>
9 <field name="arch" type="xml">8 <field name="arch" type="xml">
10 <tree string="Journal Entry Template Line">9 <tree string="Journal Entry Template Line">
11 <field name="sequence"/>10 <field name="sequence"/>
@@ -25,7 +24,6 @@
25 <record id="view_move_template_line_form" model="ir.ui.view">24 <record id="view_move_template_line_form" model="ir.ui.view">
26 <field name="name">account.move.template.line.form</field>25 <field name="name">account.move.template.line.form</field>
27 <field name="model">account.move.template.line</field>26 <field name="model">account.move.template.line</field>
28 <field name="type">form</field>
29 <field name="arch" type="xml">27 <field name="arch" type="xml">
30 <form string="Journal Entry Template Line">28 <form string="Journal Entry Template Line">
31 <field colspan="4" name="name" select="1"/>29 <field colspan="4" name="name" select="1"/>
@@ -46,7 +44,6 @@
46 <record id="view_move_template_form" model="ir.ui.view">44 <record id="view_move_template_form" model="ir.ui.view">
47 <field name="name">account.move.template.form</field>45 <field name="name">account.move.template.form</field>
48 <field name="model">account.move.template</field>46 <field name="model">account.move.template</field>
49 <field name="type">form</field>
50 <field name="arch" type="xml">47 <field name="arch" type="xml">
51 <form string="Journal Entry Template">48 <form string="Journal Entry Template">
52 <field name="name"/>49 <field name="name"/>
@@ -61,7 +58,6 @@
61 <record id="view_move_template_tree" model="ir.ui.view">58 <record id="view_move_template_tree" model="ir.ui.view">
62 <field name="name">account.move.template.tree</field>59 <field name="name">account.move.template.tree</field>
63 <field name="model">account.move.template</field>60 <field name="model">account.move.template</field>
64 <field name="type">tree</field>
65 <field name="arch" type="xml">61 <field name="arch" type="xml">
66 <tree string="Journal Entry Template">62 <tree string="Journal Entry Template">
67 <field name="name"/>63 <field name="name"/>
@@ -73,7 +69,6 @@
73 <record id="view_move_template_search" model="ir.ui.view">69 <record id="view_move_template_search" model="ir.ui.view">
74 <field name="name">account.move.template.search</field>70 <field name="name">account.move.template.search</field>
75 <field name="model">account.move.template</field>71 <field name="model">account.move.template</field>
76 <field name="type">search</field>
77 <field name="arch" type="xml">72 <field name="arch" type="xml">
78 <search string="Journal Entry Template">73 <search string="Journal Entry Template">
79 <group>74 <group>
@@ -94,6 +89,6 @@
94 </record>89 </record>
95 <menuitem90 <menuitem
96 action="action_move_template_form" id="menu_action_move_template_form" sequence="5"91 action="action_move_template_form" id="menu_action_move_template_form" sequence="5"
97 parent="account.menu_configuration_misc" groups="base.group_extended"/>92 parent="account.menu_configuration_misc" groups="account.group_account_manager"/>
98 </data>93 </data>
99</openerp>94</openerp>
10095
=== modified file 'account_move_template/wizard/select_template.py'
--- account_move_template/wizard/select_template.py 2013-01-04 13:48:18 +0000
+++ account_move_template/wizard/select_template.py 2013-06-17 10:32:31 +0000
@@ -19,11 +19,11 @@
19#19#
20##############################################################################20##############################################################################
2121
22from openerp.osv import fields,osv22from openerp.osv import fields,orm
23import time23import time
24from openerp.tools.translate import _24from openerp.tools.translate import _
2525
26class wizard_select_template(osv.osv_memory):26class wizard_select_template(orm.TransientModel):
2727
28 _name = "wizard.select.move.template"28 _name = "wizard.select.move.template"
29 _columns = {29 _columns = {
@@ -55,6 +55,8 @@
55 wizard = self.browse(cr, uid, ids, context=context)[0]55 wizard = self.browse(cr, uid, ids, context=context)[0]
56 template_pool = self.pool.get('account.move.template')56 template_pool = self.pool.get('account.move.template')
57 wizard_line_pool = self.pool.get('wizard.select.move.template.line')57 wizard_line_pool = self.pool.get('wizard.select.move.template.line')
58 model_data_obj = self.pool.get('ir.model.data')
59
58 template = template_pool.browse(cr, uid, wizard.template_id.id)60 template = template_pool.browse(cr, uid, wizard.template_id.id)
59 for line in template.template_line_ids:61 for line in template.template_line_ids:
60 if line.type == 'input':62 if line.type == 'input':
@@ -69,7 +71,20 @@
69 if not wizard.line_ids:71 if not wizard.line_ids:
70 return self.load_template(cr, uid, ids)72 return self.load_template(cr, uid, ids)
71 wizard.write({'state': 'template_selected'})73 wizard.write({'state': 'template_selected'})
72 return True74
75 view_rec = model_data_obj.get_object_reference(cr, uid, 'account_move_template', 'wizard_select_template')
76 view_id = view_rec and view_rec[1] or False
77
78 return {
79 'view_type': 'form',
80 'view_id' : [view_id],
81 'view_mode': 'form',
82 'res_model': 'wizard.select.move.template',
83 'res_id': wizard.id,
84 'type': 'ir.actions.act_window',
85 'target': 'new',
86 'context': context,
87 }
73 88
74 def load_template(self, cr, uid, ids, context=None):89 def load_template(self, cr, uid, ids, context=None):
75 template_obj = self.pool.get('account.move.template')90 template_obj = self.pool.get('account.move.template')
@@ -80,7 +95,7 @@
80 mod_obj = self.pool.get('ir.model.data')95 mod_obj = self.pool.get('ir.model.data')
81 wizard = self.browse(cr, uid, ids, context=context)[0]96 wizard = self.browse(cr, uid, ids, context=context)[0]
82 if not template_obj.check_zero_lines(cr, uid, wizard):97 if not template_obj.check_zero_lines(cr, uid, wizard):
83 raise osv.except_osv(_('Error !'), _('At least one amount has to be non-zero!'))98 raise orm.except_orm(_('Error !'), _('At least one amount has to be non-zero!'))
84 input_lines = {}99 input_lines = {}
85100
86 for template_line in wizard.line_ids:101 for template_line in wizard.line_ids:
@@ -88,7 +103,7 @@
88103
89 period_id = account_period_obj.find(cr, uid, context=context)104 period_id = account_period_obj.find(cr, uid, context=context)
90 if not period_id:105 if not period_id:
91 raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))106 raise orm.except_orm(_('No period found !'), _('Unable to find a valid period !'))
92 period_id = period_id[0]107 period_id = period_id[0]
93108
94 computed_lines = template_obj.compute_lines(cr, uid, wizard.template_id.id, input_lines)109 computed_lines = template_obj.compute_lines(cr, uid, wizard.template_id.id, input_lines)
@@ -131,7 +146,7 @@
131 analytic_account_id = False146 analytic_account_id = False
132 if line.analytic_account_id:147 if line.analytic_account_id:
133 if not line.journal_id.analytic_journal_id:148 if not line.journal_id.analytic_journal_id:
134 raise osv.except_osv(_('No Analytic Journal !'),149 raise orm.except_orm(_('No Analytic Journal !'),
135 _("You have to define an analytic journal on the '%s' journal!")150 _("You have to define an analytic journal on the '%s' journal!")
136 % (line.journal_id.name,))151 % (line.journal_id.name,))
137 analytic_account_id = line.analytic_account_id.id152 analytic_account_id = line.analytic_account_id.id
@@ -161,7 +176,7 @@
161 analytic_account_id = False176 analytic_account_id = False
162 if line.analytic_account_id:177 if line.analytic_account_id:
163 if not line.journal_id.analytic_journal_id:178 if not line.journal_id.analytic_journal_id:
164 raise osv.except_osv(_('No Analytic Journal !'),179 raise orm.except_orm(_('No Analytic Journal !'),
165 _("You have to define an analytic journal on the '%s' journal!")180 _("You have to define an analytic journal on the '%s' journal!")
166 % (wizard.template_id.journal_id.name,))181 % (wizard.template_id.journal_id.name,))
167 analytic_account_id = line.analytic_account_id.id182 analytic_account_id = line.analytic_account_id.id
@@ -181,10 +196,8 @@
181 val['debit'] = computed_lines[line.sequence]196 val['debit'] = computed_lines[line.sequence]
182 id_line = account_move_line_obj.create(cr, uid, val)197 id_line = account_move_line_obj.create(cr, uid, val)
183 return id_line198 return id_line
184
185wizard_select_template()
186199
187class wizard_select_template_line(osv.osv_memory):200class wizard_select_template_line(orm.TransientModel):
188 _description = 'Template Lines'201 _description = 'Template Lines'
189 _name = "wizard.select.move.template.line"202 _name = "wizard.select.move.template.line"
190 _columns = {203 _columns = {
@@ -198,5 +211,3 @@
198 ], 'Move Line Type', required=True,readonly=True),211 ], 'Move Line Type', required=True,readonly=True),
199 'amount': fields.float('Amount', required=True),212 'amount': fields.float('Amount', required=True),
200 }213 }
201
202wizard_select_template_line()
203214
=== modified file 'account_move_template/wizard/select_template.xml'
--- account_move_template/wizard/select_template.xml 2012-11-16 23:44:13 +0000
+++ account_move_template/wizard/select_template.xml 2013-06-17 10:32:31 +0000
@@ -5,7 +5,6 @@
5 <record id="wizard_select_template" model="ir.ui.view">5 <record id="wizard_select_template" model="ir.ui.view">
6 <field name="name">Select Move Template</field>6 <field name="name">Select Move Template</field>
7 <field name="model">wizard.select.move.template</field>7 <field name="model">wizard.select.move.template</field>
8 <field name="type">form</field>
9 <field name="arch" type="xml">8 <field name="arch" type="xml">
10 <form string="Move Template" >9 <form string="Move Template" >
11 <group col="2" width="600" height="500">10 <group col="2" width="600" height="500">
@@ -29,7 +28,6 @@
29 <record id="wizard_select_template_line" model="ir.ui.view">28 <record id="wizard_select_template_line" model="ir.ui.view">
30 <field name="name">Select Move Template Line</field>29 <field name="name">Select Move Template Line</field>
31 <field name="model">wizard.select.move.template.line</field>30 <field name="model">wizard.select.move.template.line</field>
32 <field name="type">form</field>
33 <field name="arch" type="xml">31 <field name="arch" type="xml">
34 <form string="Move Template Line">32 <form string="Move Template Line">
35 <group col="2">33 <group col="2">
@@ -46,7 +44,6 @@
46 <record id="wizard_select_template_line_tree" model="ir.ui.view">44 <record id="wizard_select_template_line_tree" model="ir.ui.view">
47 <field name="name">Select Move Template Line</field>45 <field name="name">Select Move Template Line</field>
48 <field name="model">wizard.select.move.template.line</field>46 <field name="model">wizard.select.move.template.line</field>
49 <field name="type">tree</field>
50 <field name="arch" type="xml">47 <field name="arch" type="xml">
51 <tree string="Move Template Line" editable="bottom">48 <tree string="Move Template Line" editable="bottom">
52 <field name="sequence" invisible="1"/>49 <field name="sequence" invisible="1"/>

Subscribers

People subscribed via source and target branches