Merge lp:~elbati/account-financial-tools/adding_account_move_template into lp:~account-core-editors/account-financial-tools/6.1

Proposed by Lorenzo Battistini
Status: Merged
Merged at revision: 94
Proposed branch: lp:~elbati/account-financial-tools/adding_account_move_template
Merge into: lp:~account-core-editors/account-financial-tools/6.1
Diff against target: 1379 lines (+1310/-0)
13 files modified
account_move_template/AUTHORS.txt (+4/-0)
account_move_template/__init__.py (+23/-0)
account_move_template/__openerp__.py (+48/-0)
account_move_template/account_document_template.py (+108/-0)
account_move_template/account_move_template.py (+85/-0)
account_move_template/i18n/account_move_template.pot (+282/-0)
account_move_template/i18n/it.po (+296/-0)
account_move_template/move_template.xml (+99/-0)
account_move_template/security/ir.model.access.csv (+9/-0)
account_move_template/test/generate_move.yml (+52/-0)
account_move_template/wizard/__init__.py (+21/-0)
account_move_template/wizard/select_template.py (+202/-0)
account_move_template/wizard/select_template.xml (+81/-0)
To merge this branch: bzr merge lp:~elbati/account-financial-tools/adding_account_move_template
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Lorenzo Battistini (community) Needs Resubmitting
Review via email: mp+134760@code.launchpad.net

Description of the change

Templates for Journal Entries

User can configure journal entries templates, useful for recurring entries.
The amount of each template line can be computed (through python code) or kept as user input. If user input, when using the template, user has to fill the amount of every input lines.
The journal entry form allows lo load, through a wizard, the template to use and the amounts to fill.

To post a comment you must log in.
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi,

Thank you for the proposal ! I just have a few little remarks here :

 - Import should use the full path now, so :
      - from osv import fields, osv => from openerp.osv import fields, osv
      - from tools.translate import _ => from openerp.tools.translate import _

 - On line 269, 1256 and 1256 we want to split those long line

Congratulations, cause you took time to have tests ! The rest looks good.

Regards,

95. By Lorenzo Battistini

[FIX] minor fixes

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

Hi,

I'm a bit puzzled by the 'All Rights Reserved' above the license. What would it mean ?

I think that can be merged but this notice sounds weird to me.

A note on the 'Resubmit' review type: its purpose is for a reviewer to ask for a resubmit, not for the reviewed person to express the fact that he want to submit again (you can see that you are now in the list of the reviewers of your own proposal). A comment should be sufficient for that matter.

review: Approve
96. By Lorenzo Battistini

[FIX] copyright header

Revision history for this message
Lorenzo Battistini (elbati) wrote :

On 01/03/2013 10:41 AM, Guewen Baconnier @ Camptocamp wrote:
>
> I'm a bit puzzled by the 'All Rights Reserved' above the license. What would it mean ?

I suspect we just copied and pasted it from somewhere.
Removed.

>
> A note on the 'Resubmit' review type: its purpose is for a reviewer to ask for a resubmit, not for the reviewed person to express the fact that he want to submit again (you can see that you are now in the list of the reviewers of your own proposal). A comment should be sufficient for that matter.

Ok

--
Lorenzo Battistini

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

> On 01/03/2013 10:41 AM, Guewen Baconnier @ Camptocamp wrote:
> >
> > I'm a bit puzzled by the 'All Rights Reserved' above the license. What would
> it mean ?
>
> I suspect we just copied and pasted it from somewhere.
> Removed.
>

I just saw it in one of our module, for the same reason I think ;-)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_move_template'
2=== added file 'account_move_template/AUTHORS.txt'
3--- account_move_template/AUTHORS.txt 1970-01-01 00:00:00 +0000
4+++ account_move_template/AUTHORS.txt 2013-01-04 13:50:27 +0000
5@@ -0,0 +1,4 @@
6+Davide Corio <davide.corio@agilebg.com>
7+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
8+Paolo Chiara <p.chiara@isa.it>
9+Franco Tampieri <franco.tampieri@agilebg.com>
10
11=== added file 'account_move_template/__init__.py'
12--- account_move_template/__init__.py 1970-01-01 00:00:00 +0000
13+++ account_move_template/__init__.py 2013-01-04 13:50:27 +0000
14@@ -0,0 +1,23 @@
15+# -*- coding: utf-8 -*-
16+##############################################################################
17+#
18+# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
19+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
20+#
21+# This program is free software: you can redistribute it and/or modify
22+# it under the terms of the GNU Affero General Public License as published
23+# by the Free Software Foundation, either version 3 of the License, or
24+# (at your option) any later version.
25+#
26+# This program is distributed in the hope that it will be useful,
27+# but WITHOUT ANY WARRANTY; without even the implied warranty of
28+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29+# GNU Affero General Public License for more details.
30+#
31+# You should have received a copy of the GNU Affero General Public License
32+# along with this program. If not, see <http://www.gnu.org/licenses/>.
33+#
34+##############################################################################
35+import account_document_template
36+import account_move_template
37+import wizard
38
39=== added file 'account_move_template/__openerp__.py'
40--- account_move_template/__openerp__.py 1970-01-01 00:00:00 +0000
41+++ account_move_template/__openerp__.py 2013-01-04 13:50:27 +0000
42@@ -0,0 +1,48 @@
43+# -*- coding: utf-8 -*-
44+##############################################################################
45+#
46+# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
47+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
48+#
49+# This program is free software: you can redistribute it and/or modify
50+# it under the terms of the GNU Affero General Public License as published
51+# by the Free Software Foundation, either version 3 of the License, or
52+# (at your option) any later version.
53+#
54+# This program is distributed in the hope that it will be useful,
55+# but WITHOUT ANY WARRANTY; without even the implied warranty of
56+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57+# GNU Affero General Public License for more details.
58+#
59+# You should have received a copy of the GNU Affero General Public License
60+# along with this program. If not, see <http://www.gnu.org/licenses/>.
61+#
62+##############################################################################
63+{
64+ 'name': "Account Move Template",
65+ 'version': '0.1',
66+ 'category': 'Generic Modules/Accounting',
67+ 'description': """
68+Templates for Journal Entries
69+
70+User can configure journal entries templates, useful for recurring entries.
71+The amount of each template line can be computed (through python code) or kept as user input. If user input, when using the template, user has to fill the amount of every input lines.
72+The journal entry form allows lo load, through a wizard, the template to use and the amounts to fill.
73+""",
74+ 'author': 'Agile Business Group & Domsense',
75+ 'website': 'http://www.agilebg.com',
76+ 'license': 'AGPL-3',
77+ "depends" : ['account_accountant', 'analytic'],
78+ "init_xml" : [],
79+ "update_xml" : [
80+ 'move_template.xml',
81+ 'wizard/select_template.xml',
82+ 'security/ir.model.access.csv',
83+ ],
84+ "demo_xml" : [],
85+ 'test': [
86+ 'test/generate_move.yml',
87+ ],
88+ "active": False,
89+ "installable": True
90+}
91
92=== added file 'account_move_template/account_document_template.py'
93--- account_move_template/account_document_template.py 1970-01-01 00:00:00 +0000
94+++ account_move_template/account_document_template.py 2013-01-04 13:50:27 +0000
95@@ -0,0 +1,108 @@
96+# -*- coding: utf-8 -*-
97+##############################################################################
98+#
99+# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
100+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
101+#
102+# This program is free software: you can redistribute it and/or modify
103+# it under the terms of the GNU Affero General Public License as published
104+# by the Free Software Foundation, either version 3 of the License, or
105+# (at your option) any later version.
106+#
107+# This program is distributed in the hope that it will be useful,
108+# but WITHOUT ANY WARRANTY; without even the implied warranty of
109+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
110+# GNU Affero General Public License for more details.
111+#
112+# You should have received a copy of the GNU Affero General Public License
113+# along with this program. If not, see <http://www.gnu.org/licenses/>.
114+#
115+##############################################################################
116+
117+from openerp.osv import fields, osv
118+from openerp.tools.translate import _
119+import re
120+
121+class account_document_template(osv.osv):
122+
123+ _computed_lines = {}
124+ _current_template_id = 0
125+ _cr = None
126+ _uid = None
127+ _name = 'account.document.template'
128+
129+ _columns = {
130+ 'name': fields.char('Name', size=64, required=True),
131+ }
132+
133+ def _input_lines(self, cr, uid, template):
134+ count = 0
135+ for line in template.template_line_ids:
136+ if line.type == 'input':
137+ count += 1
138+ return count
139+
140+ def _get_template_line(self, cr, uid, template_id, line_number):
141+ for line in self.browse(cr, uid, template_id).template_line_ids:
142+ if line.sequence == line_number:
143+ return line
144+ return False
145+
146+ def _generate_empty_lines(self, cr, uid, template_id):
147+ lines = {}
148+ for template_line in self.browse(cr, uid, template_id).template_line_ids:
149+ lines[template_line.sequence] = None
150+ return lines
151+
152+ def lines(self, line_number):
153+ if self._computed_lines[line_number] is not None:
154+ return self._computed_lines[line_number]
155+ line = self._get_template_line(self._cr, self._uid, self._current_template_id, line_number)
156+ if re.match('L\( *'+str(line_number)+' *\)',line.python_code):
157+ raise osv.except_osv(_('Error'),
158+ _('Line %s can\'t refer to itself') % str(line_number))
159+ try:
160+ self._computed_lines[line_number] = eval(line.python_code.replace('L', 'self.lines'))
161+ except KeyError:
162+ raise osv.except_osv(_('Error'),
163+ _('Code "%s" refers to non existing line') % line.python_code)
164+ return self._computed_lines[line_number]
165+
166+ def compute_lines(self, cr, uid, template_id, input_lines):
167+ # input_lines: dictionary in the form {line_number: line_amount}
168+ # returns all the lines (included input lines) in the form {line_number: line_amount}
169+ template = self.browse(cr, uid, template_id)
170+ if len(input_lines) != self._input_lines(cr, uid, template):
171+ raise osv.except_osv(_('Error'),
172+ _('Inconsistency between input lines and filled lines for template %s') % template.name)
173+ self._current_template_id = template.id
174+ self._cr = cr
175+ self._uid = uid
176+ self._computed_lines = self._generate_empty_lines(cr, uid, template_id)
177+ self._computed_lines.update(input_lines)
178+ for line_number in self._computed_lines:
179+ self.lines(line_number)
180+ return self._computed_lines
181+
182+ def check_zero_lines(self, cr, uid, wizard):
183+ if not wizard.line_ids:
184+ return True
185+ for template_line in wizard.line_ids:
186+ if template_line.amount:
187+ return True
188+ return False
189+
190+account_document_template()
191+
192+class account_document_template_line(osv.osv):
193+
194+ _name = 'account.document.template.line'
195+
196+ _columns = {
197+ 'name': fields.char('Name', size=64, required=True),
198+ 'sequence': fields.integer('Sequence', required=True),
199+ 'type': fields.selection([('computed', 'Computed'),('input', 'User input')], 'Type', required=True),
200+ 'python_code':fields.text('Python Code'),
201+ }
202+
203+account_document_template_line()
204
205=== added file 'account_move_template/account_move_template.py'
206--- account_move_template/account_move_template.py 1970-01-01 00:00:00 +0000
207+++ account_move_template/account_move_template.py 2013-01-04 13:50:27 +0000
208@@ -0,0 +1,85 @@
209+# -*- coding: utf-8 -*-
210+##############################################################################
211+#
212+# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
213+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
214+#
215+# This program is free software: you can redistribute it and/or modify
216+# it under the terms of the GNU Affero General Public License as published
217+# by the Free Software Foundation, either version 3 of the License, or
218+# (at your option) any later version.
219+#
220+# This program is distributed in the hope that it will be useful,
221+# but WITHOUT ANY WARRANTY; without even the implied warranty of
222+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
223+# GNU Affero General Public License for more details.
224+#
225+# You should have received a copy of the GNU Affero General Public License
226+# along with this program. If not, see <http://www.gnu.org/licenses/>.
227+#
228+##############################################################################
229+
230+from openerp.osv import fields, osv
231+from openerp.tools.translate import _
232+
233+class account_move_template(osv.osv):
234+
235+ _inherit = 'account.document.template'
236+ _name = 'account.move.template'
237+
238+ _columns = {
239+ 'company_id': fields.many2one('res.company', 'Company', required=True, change_default=True),
240+ 'template_line_ids': fields.one2many('account.move.template.line', 'template_id', 'Template Lines'),
241+ 'cross_journals': fields.boolean('Cross-Journals'),
242+ 'transitory_acc_id': fields.many2one('account.account', 'Transitory account', required=False),
243+ }
244+
245+ _defaults = {
246+ 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.template', context=c),
247+ }
248+
249+ def _check_different_journal(self, cr, uid, ids, context=None):
250+ #Check that the journal on these lines are different/same in the case of cross journals/single journal
251+ journal_ids=[]
252+ all_journal_ids=[]
253+ move_template=self.pool.get('account.move.template').browse(cr,uid,ids)[0]
254+ if not move_template.template_line_ids:
255+ return True
256+ for template_line in move_template.template_line_ids:
257+ all_journal_ids.append(template_line.journal_id.id)
258+ if template_line.journal_id.id not in journal_ids :
259+ journal_ids.append(template_line.journal_id.id)
260+ if move_template.cross_journals:
261+ return len(all_journal_ids)==len(journal_ids)
262+ else:
263+ return len(journal_ids)==1
264+
265+ _constraints = [(_check_different_journal,
266+ 'If the template is "cross-journals", the Journals must be different,' \
267+ 'if the template does not "cross-journals" the Journals must be the same!',
268+ ['journal_id'])]
269+
270+account_move_template()
271+
272+class account_move_template_line(osv.osv):
273+
274+ _name = 'account.move.template.line'
275+ _inherit = 'account.document.template.line'
276+
277+ _columns = {
278+ 'journal_id': fields.many2one('account.journal', 'Journal', required=True),
279+ 'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade"),
280+ 'move_line_type':fields.selection([
281+ ('cr','Credit'),
282+ ('dr','Debit'),
283+ ], 'Move Line Type', required=True),
284+ 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account', ondelete="cascade"),
285+ 'template_id': fields.many2one('account.move.template', 'Template'),
286+ 'account_tax_id':fields.many2one('account.tax', 'Tax'),
287+ }
288+
289+ _sql_constraints = [
290+ ('sequence_template_uniq', 'unique (template_id,sequence)', 'The sequence of the line must be unique per template !')
291+ ]
292+
293+account_move_template_line()
294
295=== added directory 'account_move_template/i18n'
296=== added file 'account_move_template/i18n/account_move_template.pot'
297--- account_move_template/i18n/account_move_template.pot 1970-01-01 00:00:00 +0000
298+++ account_move_template/i18n/account_move_template.pot 2013-01-04 13:50:27 +0000
299@@ -0,0 +1,282 @@
300+# Translation of OpenERP Server.
301+# This file contains the translation of the following modules:
302+# * account_move_template
303+#
304+msgid ""
305+msgstr ""
306+"Project-Id-Version: OpenERP Server 6.0.3\n"
307+"Report-Msgid-Bugs-To: support@openerp.com\n"
308+"POT-Creation-Date: 2011-10-31 08:58+0000\n"
309+"PO-Revision-Date: 2011-10-31 08:58+0000\n"
310+"Last-Translator: <>\n"
311+"Language-Team: \n"
312+"MIME-Version: 1.0\n"
313+"Content-Type: text/plain; charset=UTF-8\n"
314+"Content-Transfer-Encoding: \n"
315+"Plural-Forms: \n"
316+
317+#. module: account_move_template
318+#: field:account.move.template.line,move_line_type:0
319+#: field:wizard.select.move.template.line,move_line_type:0
320+msgid "Move Line Type"
321+msgstr ""
322+
323+#. module: account_move_template
324+#: model:ir.model,name:account_move_template.model_account_move_template_line
325+msgid "account.move.template.line"
326+msgstr ""
327+
328+#. module: account_move_template
329+#: view:wizard.select.move.template:0
330+#: field:wizard.select.move.template,template_id:0
331+msgid "Move Template"
332+msgstr ""
333+
334+#. module: account_move_template
335+#: model:ir.actions.act_window,name:account_move_template.action_wizard_select_template
336+msgid "Select Move Template"
337+msgstr ""
338+
339+#. module: account_move_template
340+#: model:ir.model,name:account_move_template.model_wizard_select_move_template
341+msgid "wizard.select.move.template"
342+msgstr ""
343+
344+#. module: account_move_template
345+#: model:ir.module.module,shortdesc:account_move_template.module_meta_information
346+msgid "Account Move Template"
347+msgstr ""
348+
349+#. module: account_move_template
350+#: view:account.move.template:0
351+msgid "Group By..."
352+msgstr ""
353+
354+#. module: account_move_template
355+#: code:addons/account_move_template/wizard/select_template.py:87
356+#, python-format
357+msgid "You have to define an analytic journal on the '%s' journal!"
358+msgstr ""
359+
360+#. module: account_move_template
361+#: field:account.move.template.line,template_id:0
362+#: field:wizard.select.move.template.line,template_id:0
363+msgid "Template"
364+msgstr ""
365+
366+#. module: account_move_template
367+#: selection:account.move.template.line,move_line_type:0
368+#: selection:wizard.select.move.template.line,move_line_type:0
369+msgid "Debit"
370+msgstr ""
371+
372+#. module: account_move_template
373+#: code:addons/account_move_template/wizard/select_template.py:76
374+#, python-format
375+msgid "No period found !"
376+msgstr ""
377+
378+#. module: account_move_template
379+#: field:account.document.template.line,type:0
380+#: field:account.move.template.line,type:0
381+msgid "Type"
382+msgstr ""
383+
384+#. module: account_move_template
385+#: model:ir.actions.act_window,name:account_move_template.action_wizard_select_template_by_move
386+#: model:ir.ui.menu,name:account_move_template.menu_action_wizard_select_template
387+msgid "Create Move from Template"
388+msgstr ""
389+
390+#. module: account_move_template
391+#: code:addons/account_move_template/wizard/select_template.py:67
392+#, python-format
393+msgid "Error !"
394+msgstr ""
395+
396+#. module: account_move_template
397+#: code:addons/account_move_template/wizard/select_template.py:76
398+#, python-format
399+msgid "Unable to find a valid period !"
400+msgstr ""
401+
402+#. module: account_move_template
403+#: model:ir.actions.act_window,name:account_move_template.action_move_template_form
404+#: model:ir.ui.menu,name:account_move_template.menu_action_move_template_form
405+msgid "Move Templates"
406+msgstr ""
407+
408+#. module: account_move_template
409+#: field:account.move.template,company_id:0
410+msgid "Company"
411+msgstr ""
412+
413+#. module: account_move_template
414+#: model:ir.module.module,description:account_move_template.module_meta_information
415+msgid "\n"
416+"=============================\n"
417+"Templates for Journal Entries\n"
418+"=============================\n"
419+"User can configure journal entries templates. The amount of each template line can be computed (through python code) or kept as user input. If user input, when using the template, user has to fill the amount of every input lines.\n"
420+"The journal entry form allows lo load, through a wizard, the template to use and the amounts to fill.\n"
421+""
422+msgstr ""
423+
424+#. module: account_move_template
425+#: model:ir.model,name:account_move_template.model_account_move_template
426+msgid "account.move.template"
427+msgstr ""
428+
429+#. module: account_move_template
430+#: model:ir.model,name:account_move_template.model_account_document_template_line
431+msgid "account.document.template.line"
432+msgstr ""
433+
434+#. module: account_move_template
435+#: selection:account.document.template.line,type:0
436+#: selection:account.move.template.line,type:0
437+msgid "User input"
438+msgstr ""
439+
440+#. module: account_move_template
441+#: view:account.move.template:0
442+msgid "Purchase"
443+msgstr ""
444+
445+#. module: account_move_template
446+#: field:account.move.template.line,account_id:0
447+#: field:wizard.select.move.template.line,account_id:0
448+msgid "Account"
449+msgstr ""
450+
451+#. module: account_move_template
452+#: field:account.document.template,name:0
453+#: field:account.document.template.line,name:0
454+#: field:account.move.template,name:0
455+#: field:account.move.template.line,name:0
456+#: field:wizard.select.move.template.line,name:0
457+msgid "Name"
458+msgstr ""
459+
460+#. module: account_move_template
461+#: field:wizard.select.move.template,line_ids:0
462+msgid "Lines"
463+msgstr ""
464+
465+#. module: account_move_template
466+#: view:account.move.template:0
467+msgid "Sale"
468+msgstr ""
469+
470+#. module: account_move_template
471+#: view:account.move.template.line:0
472+msgid "Journal Entry Template Line"
473+msgstr ""
474+
475+#. module: account_move_template
476+#: code:addons/account_move_template/wizard/select_template.py:67
477+#, python-format
478+msgid "At least one amount has to be non-zero!"
479+msgstr ""
480+
481+#. module: account_move_template
482+#: selection:account.move.template.line,move_line_type:0
483+#: selection:wizard.select.move.template.line,move_line_type:0
484+msgid "Credit"
485+msgstr ""
486+
487+#. module: account_move_template
488+#: field:wizard.select.move.template.line,amount:0
489+msgid "Amount"
490+msgstr ""
491+
492+#. module: account_move_template
493+#: view:account.move.template:0
494+msgid "Journal Entry Template"
495+msgstr ""
496+
497+#. module: account_move_template
498+#: code:addons/account_move_template/account_document_template.py:69
499+#, python-format
500+msgid "Error"
501+msgstr ""
502+
503+#. module: account_move_template
504+#: sql_constraint:account.move.template.line:0
505+msgid "The sequence of the line must be unique per template !"
506+msgstr ""
507+
508+#. module: account_move_template
509+#: view:wizard.select.move.template:0
510+msgid "Load"
511+msgstr ""
512+
513+#. module: account_move_template
514+#: view:account.move.template.line:0
515+msgid "You can refer to other lines using their sequence number (e.g. 'L(1)' for first line). Examples of code: 'L(1) * 0.2'; 'L(2) - L(1)'; 'L(1) + L(2) + L(3)'; '1250'"
516+msgstr ""
517+
518+#. module: account_move_template
519+#: selection:account.document.template.line,type:0
520+#: selection:account.move.template.line,type:0
521+msgid "Computed"
522+msgstr ""
523+
524+#. module: account_move_template
525+#: code:addons/account_move_template/wizard/select_template.py:87
526+#, python-format
527+msgid "No Analytic Journal !"
528+msgstr ""
529+
530+#. module: account_move_template
531+#: field:account.document.template.line,python_code:0
532+#: view:account.move.template.line:0
533+#: field:account.move.template.line,python_code:0
534+msgid "Python Code"
535+msgstr ""
536+
537+#. module: account_move_template
538+#: code:addons/account_move_template/account_document_template.py:70
539+#, python-format
540+msgid "Inconsistency between input lines and filled lines for template %s"
541+msgstr ""
542+
543+#. module: account_move_template
544+#: view:wizard.select.move.template.line:0
545+msgid "Move Template Line"
546+msgstr ""
547+
548+#. module: account_move_template
549+#: field:account.document.template.line,sequence:0
550+#: field:account.move.template.line,sequence:0
551+#: field:wizard.select.move.template.line,sequence:0
552+msgid "Number"
553+msgstr ""
554+
555+#. module: account_move_template
556+#: field:account.move.template.line,analytic_account_id:0
557+msgid "Analytic Account"
558+msgstr ""
559+
560+#. module: account_move_template
561+#: view:wizard.select.move.template:0
562+msgid "Cancel"
563+msgstr ""
564+
565+#. module: account_move_template
566+#: field:account.move.template,template_line_ids:0
567+#: model:ir.model,name:account_move_template.model_wizard_select_move_template_line
568+msgid "Template Lines"
569+msgstr ""
570+
571+#. module: account_move_template
572+#: model:ir.model,name:account_move_template.model_account_document_template
573+msgid "account.document.template"
574+msgstr ""
575+
576+#. module: account_move_template
577+#: view:account.move.template:0
578+#: field:account.move.template,journal_id:0
579+msgid "Journal"
580+msgstr ""
581+
582
583=== added file 'account_move_template/i18n/it.po'
584--- account_move_template/i18n/it.po 1970-01-01 00:00:00 +0000
585+++ account_move_template/i18n/it.po 2013-01-04 13:50:27 +0000
586@@ -0,0 +1,296 @@
587+# Translation of OpenERP Server.
588+# This file contains the translation of the following modules:
589+# * account_move_template
590+#
591+msgid ""
592+msgstr ""
593+"Project-Id-Version: OpenERP Server 6.1\n"
594+"Report-Msgid-Bugs-To: \n"
595+"POT-Creation-Date: 2012-04-05 08:19+0000\n"
596+"PO-Revision-Date: 2012-04-05 10:21+0100\n"
597+"Last-Translator: eLBati <lorenzo.battistini@domsense.com>\n"
598+"Language-Team: \n"
599+"MIME-Version: 1.0\n"
600+"Content-Type: text/plain; charset=UTF-8\n"
601+"Content-Transfer-Encoding: 8bit\n"
602+"Plural-Forms: \n"
603+
604+#. module: account_move_template
605+#: field:account.move.template.line,move_line_type:0
606+#: field:wizard.select.move.template.line,move_line_type:0
607+msgid "Move Line Type"
608+msgstr "Tipo di movimento"
609+
610+#. module: account_move_template
611+#: selection:wizard.select.move.template,state:0
612+msgid "Template selected"
613+msgstr "Template selezionato"
614+
615+#. module: account_move_template
616+#: view:wizard.select.move.template:0
617+#: field:wizard.select.move.template,template_id:0
618+msgid "Move Template"
619+msgstr "Template di registrazione"
620+
621+#. module: account_move_template
622+#: model:ir.actions.act_window,name:account_move_template.action_wizard_select_template
623+msgid "Select Move Template"
624+msgstr "Scegli template di registrazione"
625+
626+#. module: account_move_template
627+#: model:ir.model,name:account_move_template.model_wizard_select_move_template
628+msgid "wizard.select.move.template"
629+msgstr "wizard.select.move.template"
630+
631+#. module: account_move_template
632+#: view:wizard.select.move.template:0
633+msgid "Next"
634+msgstr "Avanti"
635+
636+#. module: account_move_template
637+#: field:wizard.select.move.template,state:0
638+msgid "State"
639+msgstr "State"
640+
641+#. module: account_move_template
642+#: code:addons/account_move_template/wizard/select_template.py:134
643+#: code:addons/account_move_template/wizard/select_template.py:162
644+#, python-format
645+msgid "You have to define an analytic journal on the '%s' journal!"
646+msgstr "E' necessario definire un giornale analitico sul sezionale '%s'!"
647+
648+#. module: account_move_template
649+#: field:account.move.template.line,template_id:0
650+#: field:wizard.select.move.template.line,template_id:0
651+msgid "Template"
652+msgstr "Template"
653+
654+#. module: account_move_template
655+#: selection:account.move.template.line,move_line_type:0
656+#: selection:wizard.select.move.template.line,move_line_type:0
657+msgid "Debit"
658+msgstr "Dare"
659+
660+#. module: account_move_template
661+#: code:addons/account_move_template/wizard/select_template.py:91
662+#, python-format
663+msgid "No period found !"
664+msgstr "Nessun periodo trovato!"
665+
666+#. module: account_move_template
667+#: field:account.document.template.line,type:0
668+#: field:account.move.template.line,type:0
669+msgid "Type"
670+msgstr "Tipo"
671+
672+#. module: account_move_template
673+#: field:account.move.template.line,analytic_account_id:0
674+msgid "Analytic Account"
675+msgstr "Conto analitico"
676+
677+#. module: account_move_template
678+#: code:addons/account_move_template/wizard/select_template.py:83
679+#, python-format
680+msgid "Error !"
681+msgstr "Errore !"
682+
683+#. module: account_move_template
684+#: code:addons/account_move_template/wizard/select_template.py:91
685+#, python-format
686+msgid "Unable to find a valid period !"
687+msgstr "Impossibile trovare un periodo valido!"
688+
689+#. module: account_move_template
690+#: model:ir.actions.act_window,name:account_move_template.action_move_template_form
691+#: model:ir.ui.menu,name:account_move_template.menu_action_move_template_form
692+msgid "Move Templates"
693+msgstr "Template di registrazioni"
694+
695+#. module: account_move_template
696+#: field:account.move.template,company_id:0
697+msgid "Company"
698+msgstr "Azienda"
699+
700+#. module: account_move_template
701+#: view:wizard.select.move.template.line:0
702+msgid "Move Template Line"
703+msgstr "Riga template di registrazione"
704+
705+#. module: account_move_template
706+#: model:ir.model,name:account_move_template.model_account_move_template
707+msgid "account.move.template"
708+msgstr "account.move.template"
709+
710+#. module: account_move_template
711+#: field:account.move.template,transitory_acc_id:0
712+msgid "Transitory account"
713+msgstr "Transitory account"
714+
715+#. module: account_move_template
716+#: selection:account.document.template.line,type:0
717+#: selection:account.move.template.line,type:0
718+msgid "User input"
719+msgstr "Input utente"
720+
721+#. module: account_move_template
722+#: field:account.move.template.line,account_id:0
723+#: field:wizard.select.move.template.line,account_id:0
724+msgid "Account"
725+msgstr "Conto"
726+
727+#. module: account_move_template
728+#: field:account.document.template,name:0
729+#: field:account.document.template.line,name:0
730+#: field:account.move.template,name:0
731+#: field:account.move.template.line,name:0
732+#: field:wizard.select.move.template.line,name:0
733+msgid "Name"
734+msgstr "Nome"
735+
736+#. module: account_move_template
737+#: field:account.move.template,cross_journals:0
738+msgid "Cross-Journals"
739+msgstr "Cross-Journals"
740+
741+#. module: account_move_template
742+#: field:wizard.select.move.template,line_ids:0
743+msgid "Lines"
744+msgstr "Righe"
745+
746+#. module: account_move_template
747+#: view:account.move.template.line:0
748+msgid "Journal Entry Template Line"
749+msgstr "Riga del template di registrazione"
750+
751+#. module: account_move_template
752+#: model:ir.model,name:account_move_template.model_account_move_template_line
753+msgid "account.move.template.line"
754+msgstr "account.move.template.line"
755+
756+#. module: account_move_template
757+#: code:addons/account_move_template/wizard/select_template.py:83
758+#, python-format
759+msgid "At least one amount has to be non-zero!"
760+msgstr "Almeno un importo deve essere diverso da zero!"
761+
762+#. module: account_move_template
763+#: selection:account.move.template.line,move_line_type:0
764+#: selection:wizard.select.move.template.line,move_line_type:0
765+msgid "Credit"
766+msgstr "Avere"
767+
768+#. module: account_move_template
769+#: field:wizard.select.move.template.line,amount:0
770+msgid "Amount"
771+msgstr "Importo"
772+
773+#. module: account_move_template
774+#: view:account.move.template:0
775+msgid "Journal Entry Template"
776+msgstr "Template di registrazione contabile"
777+
778+#. module: account_move_template
779+#: code:addons/account_move_template/account_document_template.py:69
780+#, python-format
781+msgid "Error"
782+msgstr "Errore"
783+
784+#. module: account_move_template
785+#: sql_constraint:account.move.template.line:0
786+msgid "The sequence of the line must be unique per template !"
787+msgstr "Il numero della riga deve essere unico per template!"
788+
789+#. module: account_move_template
790+#: view:wizard.select.move.template:0
791+msgid "Load"
792+msgstr "Carica"
793+
794+#. module: account_move_template
795+#: view:account.move.template.line:0
796+msgid "You can refer to other lines using their sequence number (e.g. 'L(1)' for first line). Examples of code: 'L(1) * 0.2'; 'L(2) - L(1)'; 'L(1) + L(2) + L(3)'; '1250'"
797+msgstr "Si può fare riferimento alle altre righe usando il loro numero di sequenza (ad es. 'L(1)' per la prima riga). Esempi di codice: 'L(1) * 0.2'; 'L(2) - L(1)'; 'L(1) + L(2) + L(3)'; '1250'"
798+
799+#. module: account_move_template
800+#: selection:account.document.template.line,type:0
801+#: selection:account.move.template.line,type:0
802+msgid "Computed"
803+msgstr "Calcolato"
804+
805+#. module: account_move_template
806+#: code:addons/account_move_template/wizard/select_template.py:134
807+#: code:addons/account_move_template/wizard/select_template.py:162
808+#, python-format
809+msgid "No Analytic Journal !"
810+msgstr "Nessun giornale analitico!"
811+
812+#. module: account_move_template
813+#: model:ir.model,name:account_move_template.model_account_document_template_line
814+msgid "account.document.template.line"
815+msgstr "account.document.template.line"
816+
817+#. module: account_move_template
818+#: field:account.document.template.line,python_code:0
819+#: view:account.move.template.line:0
820+#: field:account.move.template.line,python_code:0
821+msgid "Python Code"
822+msgstr "Codice python"
823+
824+#. module: account_move_template
825+#: code:addons/account_move_template/account_document_template.py:70
826+#, python-format
827+msgid "Inconsistency between input lines and filled lines for template %s"
828+msgstr "Inconsistenza fra le righe di input previste ed inserite per il template %s"
829+
830+#. module: account_move_template
831+#: field:account.move.template.line,account_tax_id:0
832+msgid "Tax"
833+msgstr "Imposta"
834+
835+#. module: account_move_template
836+#: field:wizard.select.move.template.line,sequence:0
837+msgid "Number"
838+msgstr "Numero"
839+
840+#. module: account_move_template
841+#: model:ir.actions.act_window,name:account_move_template.action_wizard_select_template_by_move
842+#: model:ir.ui.menu,name:account_move_template.menu_action_wizard_select_template
843+msgid "Create Move from Template"
844+msgstr "Crea registrazione da template"
845+
846+#. module: account_move_template
847+#: field:account.document.template.line,sequence:0
848+#: field:account.move.template.line,sequence:0
849+msgid "Sequence"
850+msgstr "Numero Sequenza"
851+
852+#. module: account_move_template
853+#: constraint:account.move.template:0
854+msgid "If the template is \"cross-journals\", the Journals must be different, if the template does not \"cross-journals\" the Journals must be the same!"
855+msgstr "If the template is \"cross-journals\", the Journals must be different, if the template does not \"cross-journals\" the Journals must be the same!"
856+
857+#. module: account_move_template
858+#: field:account.move.template,template_line_ids:0
859+#: model:ir.model,name:account_move_template.model_wizard_select_move_template_line
860+msgid "Template Lines"
861+msgstr "Righe template"
862+
863+#. module: account_move_template
864+#: view:wizard.select.move.template:0
865+msgid "Cancel"
866+msgstr "Annulla"
867+
868+#. module: account_move_template
869+#: field:wizard.select.move.template,partner_id:0
870+msgid "Partner"
871+msgstr "Partner"
872+
873+#. module: account_move_template
874+#: model:ir.model,name:account_move_template.model_account_document_template
875+msgid "account.document.template"
876+msgstr "account.document.template"
877+
878+#. module: account_move_template
879+#: field:account.move.template.line,journal_id:0
880+msgid "Journal"
881+msgstr "Sezionale"
882+
883
884=== added file 'account_move_template/move_template.xml'
885--- account_move_template/move_template.xml 1970-01-01 00:00:00 +0000
886+++ account_move_template/move_template.xml 2013-01-04 13:50:27 +0000
887@@ -0,0 +1,99 @@
888+<?xml version="1.0" encoding="utf-8"?>
889+<openerp>
890+ <data>
891+
892+ <record id="view_move_template_line_tree" model="ir.ui.view">
893+ <field name="name">account.move.template.line.tree</field>
894+ <field name="model">account.move.template.line</field>
895+ <field name="type">tree</field>
896+ <field name="arch" type="xml">
897+ <tree string="Journal Entry Template Line">
898+ <field name="sequence"/>
899+ <field name="name"/>
900+ <field name="journal_id"/>
901+ <field name="account_id" />
902+ <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
903+ <field name="type"/>
904+ <field name="python_code" />
905+ <field name="move_line_type"/>
906+ <field name="account_tax_id"/>
907+ </tree>
908+ </field>
909+ </record>
910+
911+
912+ <record id="view_move_template_line_form" model="ir.ui.view">
913+ <field name="name">account.move.template.line.form</field>
914+ <field name="model">account.move.template.line</field>
915+ <field name="type">form</field>
916+ <field name="arch" type="xml">
917+ <form string="Journal Entry Template Line">
918+ <field colspan="4" name="name" select="1"/>
919+ <field name="sequence"/>
920+ <field name="journal_id"/>
921+ <field name="account_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
922+ <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
923+ <field name="type"/>
924+ <field name="move_line_type"/>
925+ <field name="account_tax_id"/>
926+ <separator string="Python Code" colspan="4"/>
927+ <field name="python_code" colspan="4" attrs="{'readonly': [('type', '!=', 'computed')]}" nolabel="1"/>
928+ <label string="You can refer to other lines using their sequence number (e.g. 'L(1)' for first line). Examples of code: 'L(1) * 0.2'; 'L(2) - L(1)'; 'L(1) + L(2) + L(3)'; '1250'" colspan="4"/>
929+ </form>
930+ </field>
931+ </record>
932+
933+ <record id="view_move_template_form" model="ir.ui.view">
934+ <field name="name">account.move.template.form</field>
935+ <field name="model">account.move.template</field>
936+ <field name="type">form</field>
937+ <field name="arch" type="xml">
938+ <form string="Journal Entry Template">
939+ <field name="name"/>
940+ <field name="company_id" widget='selection' groups="base.group_multi_company"/>
941+ <field name="cross_journals" />
942+ <field name="transitory_acc_id" attrs="{'invisible':[('cross_journals','!=',True)],'required':[('cross_journals','==',True)]}"/>
943+ <field colspan="4" nolabel="1" name="template_line_ids"/>
944+ </form>
945+ </field>
946+ </record>
947+
948+ <record id="view_move_template_tree" model="ir.ui.view">
949+ <field name="name">account.move.template.tree</field>
950+ <field name="model">account.move.template</field>
951+ <field name="type">tree</field>
952+ <field name="arch" type="xml">
953+ <tree string="Journal Entry Template">
954+ <field name="name"/>
955+ <field name="company_id" groups="base.group_multi_company"/>
956+ </tree>
957+ </field>
958+ </record>
959+
960+ <record id="view_move_template_search" model="ir.ui.view">
961+ <field name="name">account.move.template.search</field>
962+ <field name="model">account.move.template</field>
963+ <field name="type">search</field>
964+ <field name="arch" type="xml">
965+ <search string="Journal Entry Template">
966+ <group>
967+ <separator orientation="vertical"/>
968+ <field name="name"/>
969+ <field name="company_id" widget="selection" groups="base.group_multi_company"/>
970+ </group>
971+ </search>
972+ </field>
973+ </record>
974+
975+ <record id="action_move_template_form" model="ir.actions.act_window">
976+ <field name="name">Move Templates</field>
977+ <field name="res_model">account.move.template</field>
978+ <field name="view_type">form</field>
979+ <field name="view_mode">tree,form</field>
980+ <field name="search_view_id" ref="view_move_template_search"/>
981+ </record>
982+ <menuitem
983+ action="action_move_template_form" id="menu_action_move_template_form" sequence="5"
984+ parent="account.menu_configuration_misc" groups="base.group_extended"/>
985+ </data>
986+</openerp>
987
988=== added directory 'account_move_template/security'
989=== added file 'account_move_template/security/ir.model.access.csv'
990--- account_move_template/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
991+++ account_move_template/security/ir.model.access.csv 2013-01-04 13:50:27 +0000
992@@ -0,0 +1,9 @@
993+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
994+"access_account_document_template_user","account_document_template_user","model_account_document_template","account.group_account_user","1","1","1","1"
995+"access_account_document_template_manager","account_document_template_manager","model_account_document_template","account.group_account_manager","1","1","1","1"
996+"access_account_document_template_line_user","account_document_template_line_user","model_account_document_template_line","account.group_account_user","1","1","1","1"
997+"access_account_document_template_line_manager","account_document_template_line_manager","model_account_document_template_line","account.group_account_manager","1","1","1","1"
998+"access_account_move_template_user","account_move_template_user","model_account_move_template","account.group_account_user","1","1","1","1"
999+"access_account_move_template_manager","account_move_template_manager","model_account_move_template","account.group_account_manager","1","1","1","1"
1000+"access_account_move_template_line_user","account_move_template_line_user","model_account_move_template_line","account.group_account_user","1","1","1","1"
1001+"access_account_move_template_line_manager","account_move_template_line_manager","model_account_move_template_line","account.group_account_manager","1","1","1","1"
1002
1003=== added directory 'account_move_template/test'
1004=== added file 'account_move_template/test/generate_move.yml'
1005--- account_move_template/test/generate_move.yml 1970-01-01 00:00:00 +0000
1006+++ account_move_template/test/generate_move.yml 2013-01-04 13:50:27 +0000
1007@@ -0,0 +1,52 @@
1008+-
1009+ I first create a move template for received bank payment. Two lines, bank and credit
1010+-
1011+ !record {model: account.move.template, id: move_template_1}:
1012+ company_id: base.main_company
1013+ name: "First template"
1014+ template_line_ids:
1015+ - name: "Bank"
1016+ sequence: 1
1017+ journal_id: account.bank_journal
1018+ account_id: account.bnk
1019+ type: 'input'
1020+ move_line_type: 'dr'
1021+ - name: "Credit"
1022+ sequence: 2
1023+ journal_id: account.bank_journal
1024+ account_id: account.a_recv
1025+ type: 'computed'
1026+ move_line_type: 'cr'
1027+ python_code: 'L(1)'
1028+
1029+-
1030+ I use "Select Move Template" wizard to generate move
1031+-
1032+ !record {model: wizard.select.move.template, id: wizard_select_move_template_1}:
1033+ template_id: move_template_1
1034+
1035+-
1036+ I click on Next Button
1037+-
1038+ !python {model: wizard.select.move.template}: |
1039+ self.load_lines(cr, uid, [ref("wizard_select_move_template_1")])
1040+
1041+-
1042+ I verify that wizard lines are created and write the amount line
1043+-
1044+ !python {model: wizard.select.move.template}: |
1045+ wizard = self.browse(cr, uid, ref('wizard_select_move_template_1'))
1046+ assert(len(wizard.line_ids) == 1), ('Wrong number of wizard lines')
1047+ wizard.line_ids[0].write({'amount': 100.0})
1048+
1049+-
1050+ I click on Load Button and check the created move
1051+-
1052+ !python {model: wizard.select.move.template}: |
1053+ action = self.load_template(cr, uid, [ref("wizard_select_move_template_1")])
1054+ move_obj = self.pool.get('account.move')
1055+ domain_list = eval(action['domain'])
1056+ for move_id in domain_list[0][2]:
1057+ move = move_obj.browse(cr, uid, move_id)
1058+ for line in move.line_id:
1059+ assert(line.state == 'valid'), ('Move lines must be valid')
1060
1061=== added directory 'account_move_template/wizard'
1062=== added file 'account_move_template/wizard/__init__.py'
1063--- account_move_template/wizard/__init__.py 1970-01-01 00:00:00 +0000
1064+++ account_move_template/wizard/__init__.py 2013-01-04 13:50:27 +0000
1065@@ -0,0 +1,21 @@
1066+# -*- coding: utf-8 -*-
1067+##############################################################################
1068+#
1069+# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
1070+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
1071+#
1072+# This program is free software: you can redistribute it and/or modify
1073+# it under the terms of the GNU Affero General Public License as published
1074+# by the Free Software Foundation, either version 3 of the License, or
1075+# (at your option) any later version.
1076+#
1077+# This program is distributed in the hope that it will be useful,
1078+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1079+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1080+# GNU Affero General Public License for more details.
1081+#
1082+# You should have received a copy of the GNU Affero General Public License
1083+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1084+#
1085+##############################################################################
1086+import select_template
1087
1088=== added file 'account_move_template/wizard/select_template.py'
1089--- account_move_template/wizard/select_template.py 1970-01-01 00:00:00 +0000
1090+++ account_move_template/wizard/select_template.py 2013-01-04 13:50:27 +0000
1091@@ -0,0 +1,202 @@
1092+# -*- coding: utf-8 -*-
1093+##############################################################################
1094+#
1095+# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
1096+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
1097+#
1098+# This program is free software: you can redistribute it and/or modify
1099+# it under the terms of the GNU Affero General Public License as published
1100+# by the Free Software Foundation, either version 3 of the License, or
1101+# (at your option) any later version.
1102+#
1103+# This program is distributed in the hope that it will be useful,
1104+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1105+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1106+# GNU Affero General Public License for more details.
1107+#
1108+# You should have received a copy of the GNU Affero General Public License
1109+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1110+#
1111+##############################################################################
1112+
1113+from openerp.osv import fields,osv
1114+import time
1115+from openerp.tools.translate import _
1116+
1117+class wizard_select_template(osv.osv_memory):
1118+
1119+ _name = "wizard.select.move.template"
1120+ _columns = {
1121+ 'template_id': fields.many2one('account.move.template', 'Move Template', required=True),
1122+ 'partner_id': fields.many2one('res.partner', 'Partner'),
1123+ 'line_ids': fields.one2many('wizard.select.move.template.line', 'template_id', 'Lines'),
1124+ 'state': fields.selection([
1125+ ('template_selected','Template selected'),
1126+ ], 'State'),
1127+ }
1128+
1129+ def on_change_template_id(self, cr, uid, ids, template_id):
1130+ res = {}
1131+ if template_id:
1132+ res['value'] = {'line_ids': []}
1133+ template_pool = self.pool.get('account.move.template')
1134+ template = template_pool.browse(cr, uid, template_id)
1135+ for line in template.template_line_ids:
1136+ if line.type == 'input':
1137+ res['value']['line_ids'].append({
1138+ 'sequence': line.sequence,
1139+ 'name': line.name,
1140+ 'account_id': line.account_id.id,
1141+ 'move_line_type': line.move_line_type,
1142+ })
1143+ return res
1144+
1145+ def load_lines(self, cr, uid, ids, context=None):
1146+ wizard = self.browse(cr, uid, ids, context=context)[0]
1147+ template_pool = self.pool.get('account.move.template')
1148+ wizard_line_pool = self.pool.get('wizard.select.move.template.line')
1149+ template = template_pool.browse(cr, uid, wizard.template_id.id)
1150+ for line in template.template_line_ids:
1151+ if line.type == 'input':
1152+ wizard_line_pool.create(cr, uid,{
1153+ 'template_id': wizard.id,
1154+ 'sequence': line.sequence,
1155+ 'name': line.name,
1156+ 'amount': 0.0,
1157+ 'account_id': line.account_id.id,
1158+ 'move_line_type': line.move_line_type,
1159+ })
1160+ if not wizard.line_ids:
1161+ return self.load_template(cr, uid, ids)
1162+ wizard.write({'state': 'template_selected'})
1163+ return True
1164+
1165+ def load_template(self, cr, uid, ids, context=None):
1166+ template_obj = self.pool.get('account.move.template')
1167+ template_line_obj = self.pool.get('account.move.template.line')
1168+ account_period_obj = self.pool.get('account.period')
1169+
1170+
1171+ mod_obj = self.pool.get('ir.model.data')
1172+ wizard = self.browse(cr, uid, ids, context=context)[0]
1173+ if not template_obj.check_zero_lines(cr, uid, wizard):
1174+ raise osv.except_osv(_('Error !'), _('At least one amount has to be non-zero!'))
1175+ input_lines = {}
1176+
1177+ for template_line in wizard.line_ids:
1178+ input_lines[template_line.sequence] = template_line.amount
1179+
1180+ period_id = account_period_obj.find(cr, uid, context=context)
1181+ if not period_id:
1182+ raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
1183+ period_id = period_id[0]
1184+
1185+ computed_lines = template_obj.compute_lines(cr, uid, wizard.template_id.id, input_lines)
1186+
1187+ moves={}
1188+ for line in wizard.template_id.template_line_ids:
1189+ if line.journal_id.id not in moves:
1190+ moves[line.journal_id.id]=self._make_move(
1191+ cr,uid,wizard.template_id.name,period_id,line.journal_id.id, wizard.partner_id.id)
1192+
1193+ id_line=self._make_move_line(cr,uid,line,computed_lines,moves[line.journal_id.id],period_id,
1194+ wizard.partner_id.id)
1195+ if wizard.template_id.cross_journals :
1196+ trans_account_id=wizard.template_id.transitory_acc_id.id
1197+ id_trans_line=self._make_transitory_move_line(cr,uid,line,computed_lines,
1198+ moves[line.journal_id.id],period_id,trans_account_id, wizard.partner_id.id)
1199+
1200+ return {
1201+ 'domain': "[('id','in', "+str(moves.values())+")]",
1202+ 'name': 'Entries',
1203+ 'view_type': 'form',
1204+ 'view_mode': 'tree,form',
1205+ 'res_model': 'account.move',
1206+ 'type': 'ir.actions.act_window',
1207+ 'target': 'current',
1208+ }
1209+ #'res_id': moves.values() or False,
1210+ def _make_move(self, cr, uid,ref,period_id,journal_id, partner_id):
1211+ account_move_obj = self.pool.get('account.move')
1212+ move_id = account_move_obj.create(cr, uid, {
1213+ 'ref': ref,
1214+ 'period_id': period_id,
1215+ 'journal_id': journal_id,
1216+ 'partner_id': partner_id,
1217+ })
1218+ return move_id
1219+
1220+ def _make_move_line(self,cr,uid,line,computed_lines,move_id,period_id, partner_id):
1221+ account_move_line_obj = self.pool.get('account.move.line')
1222+ analytic_account_id = False
1223+ if line.analytic_account_id:
1224+ if not line.journal_id.analytic_journal_id:
1225+ raise osv.except_osv(_('No Analytic Journal !'),
1226+ _("You have to define an analytic journal on the '%s' journal!")
1227+ % (line.journal_id.name,))
1228+ analytic_account_id = line.analytic_account_id.id
1229+ val = {
1230+ 'name': line.name,
1231+ 'move_id': move_id,
1232+ 'journal_id': line.journal_id.id,
1233+ 'period_id': period_id,
1234+ 'analytic_account_id': analytic_account_id,
1235+ 'account_id': line.account_id.id,
1236+ 'date': time.strftime('%Y-%m-%d'),
1237+ 'account_tax_id': line.account_tax_id.id,
1238+ 'credit': 0.0,
1239+ 'debit': 0.0,
1240+ 'partner_id': partner_id,
1241+ }
1242+ if line.move_line_type == 'cr':
1243+ val['credit'] = computed_lines[line.sequence]
1244+ if line.move_line_type == 'dr':
1245+ val['debit'] = computed_lines[line.sequence]
1246+ id_line = account_move_line_obj.create(cr, uid, val)
1247+ return id_line
1248+
1249+ def _make_transitory_move_line(
1250+ self,cr,uid,line,computed_lines,move_id,period_id,trans_account_id, partner_id):
1251+ account_move_line_obj = self.pool.get('account.move.line')
1252+ analytic_account_id = False
1253+ if line.analytic_account_id:
1254+ if not line.journal_id.analytic_journal_id:
1255+ raise osv.except_osv(_('No Analytic Journal !'),
1256+ _("You have to define an analytic journal on the '%s' journal!")
1257+ % (wizard.template_id.journal_id.name,))
1258+ analytic_account_id = line.analytic_account_id.id
1259+ val = {
1260+ 'name': 'transitory',
1261+ 'move_id': move_id,
1262+ 'journal_id': line.journal_id.id,
1263+ 'period_id': period_id,
1264+ 'analytic_account_id': analytic_account_id,
1265+ 'account_id': trans_account_id,
1266+ 'date': time.strftime('%Y-%m-%d'),
1267+ 'partner_id': partner_id,
1268+ }
1269+ if line.move_line_type != 'cr':
1270+ val['credit'] = computed_lines[line.sequence]
1271+ if line.move_line_type != 'dr':
1272+ val['debit'] = computed_lines[line.sequence]
1273+ id_line = account_move_line_obj.create(cr, uid, val)
1274+ return id_line
1275+
1276+wizard_select_template()
1277+
1278+class wizard_select_template_line(osv.osv_memory):
1279+ _description = 'Template Lines'
1280+ _name = "wizard.select.move.template.line"
1281+ _columns = {
1282+ 'template_id': fields.many2one('wizard.select.move.template', 'Template'),
1283+ 'sequence': fields.integer('Number', required=True),
1284+ 'name': fields.char('Name', size=64, required=True, readonly=True),
1285+ 'account_id': fields.many2one('account.account', 'Account', required=True, readonly=True),
1286+ 'move_line_type':fields.selection([
1287+ ('cr','Credit'),
1288+ ('dr','Debit'),
1289+ ], 'Move Line Type', required=True,readonly=True),
1290+ 'amount': fields.float('Amount', required=True),
1291+ }
1292+
1293+wizard_select_template_line()
1294
1295=== added file 'account_move_template/wizard/select_template.xml'
1296--- account_move_template/wizard/select_template.xml 1970-01-01 00:00:00 +0000
1297+++ account_move_template/wizard/select_template.xml 2013-01-04 13:50:27 +0000
1298@@ -0,0 +1,81 @@
1299+<?xml version="1.0" encoding="utf-8"?>
1300+<openerp>
1301+ <data>
1302+
1303+ <record id="wizard_select_template" model="ir.ui.view">
1304+ <field name="name">Select Move Template</field>
1305+ <field name="model">wizard.select.move.template</field>
1306+ <field name="type">form</field>
1307+ <field name="arch" type="xml">
1308+ <form string="Move Template" >
1309+ <group col="2" width="600" height="500">
1310+ <group>
1311+ <field name="template_id" colspan="2" attrs="{'invisible':[('state','=','template_selected')]}"/>
1312+ <field name="partner_id" colspan="2" attrs="{'invisible':[('state','=','template_selected')]}"/>
1313+ <field name="line_ids" colspan="2" nolabel="1" attrs="{'invisible':[('state','!=','template_selected')]}"/>
1314+ <field name="state" invisible="1"/>
1315+ </group>
1316+ <newline/>
1317+ <group col="3">
1318+ <button icon="gtk-cancel" special="cancel" string="Cancel" colspan="1"/>
1319+ <button icon="gtk-ok" name="load_template" string="Load" type="object" colspan="1" attrs="{'invisible':[('state','!=','template_selected')]}" />
1320+ <button name="load_lines" string="Next" icon="terp-gtk-go-back-rtl" type="object" colspan="1" attrs="{'invisible':[('state','=','template_selected')]}" />
1321+ </group>
1322+ </group>
1323+ </form>
1324+ </field>
1325+ </record>
1326+
1327+ <record id="wizard_select_template_line" model="ir.ui.view">
1328+ <field name="name">Select Move Template Line</field>
1329+ <field name="model">wizard.select.move.template.line</field>
1330+ <field name="type">form</field>
1331+ <field name="arch" type="xml">
1332+ <form string="Move Template Line">
1333+ <group col="2">
1334+ <field name="sequence" invisible="1"/>
1335+ <field name="name" />
1336+ <field name="account_id" />
1337+ <field name="move_line_type" />
1338+ <field name="amount" />
1339+ </group>
1340+ </form>
1341+ </field>
1342+ </record>
1343+
1344+ <record id="wizard_select_template_line_tree" model="ir.ui.view">
1345+ <field name="name">Select Move Template Line</field>
1346+ <field name="model">wizard.select.move.template.line</field>
1347+ <field name="type">tree</field>
1348+ <field name="arch" type="xml">
1349+ <tree string="Move Template Line" editable="bottom">
1350+ <field name="sequence" invisible="1"/>
1351+ <field name="name" />
1352+ <field name="account_id" />
1353+ <field name="move_line_type" />
1354+ <field name="amount" />
1355+ </tree>
1356+ </field>
1357+ </record>
1358+
1359+ <record id="action_wizard_select_template" model="ir.actions.act_window">
1360+ <field name="name">Select Move Template</field>
1361+ <field name="res_model">wizard.select.move.template</field>
1362+ <field name="view_type">form</field>
1363+ <field name="view_mode">form</field>
1364+ <field name="view_id" ref="wizard_select_template"/>
1365+ <field name="target">new</field>
1366+ </record>
1367+
1368+ <act_window name="Create Move from Template"
1369+ res_model="wizard.select.move.template"
1370+ src_model="account.move"
1371+ view_mode="form"
1372+ target="new"
1373+ key2="client_action_multi"
1374+ id="action_wizard_select_template_by_move"
1375+ view_id="wizard_select_template"/>
1376+
1377+ <menuitem name="Create Move from Template" action="action_wizard_select_template" id="menu_action_wizard_select_template" sequence="10" parent="account.menu_finance_entries"/>
1378+ </data>
1379+</openerp>

Subscribers

People subscribed via source and target branches