Merge lp:~domsense/account-financial-tools/adding_account_invoice_template into lp:~account-core-editors/account-financial-tools/6.1

Proposed by Lorenzo Battistini
Status: Merged
Merged at revision: 102
Proposed branch: lp:~domsense/account-financial-tools/adding_account_invoice_template
Merge into: lp:~account-core-editors/account-financial-tools/6.1
Diff against target: 999 lines (+941/-0)
11 files modified
account_invoice_template/AUTHORS.txt (+3/-0)
account_invoice_template/__init__.py (+22/-0)
account_invoice_template/__openerp__.py (+45/-0)
account_invoice_template/account_invoice_template.py (+99/-0)
account_invoice_template/i18n/account_invoice_template.pot (+204/-0)
account_invoice_template/i18n/it.po (+228/-0)
account_invoice_template/invoice_template.xml (+103/-0)
account_invoice_template/security/ir.model.access.csv (+5/-0)
account_invoice_template/wizard/__init__.py (+21/-0)
account_invoice_template/wizard/select_template.py (+133/-0)
account_invoice_template/wizard/select_template.xml (+78/-0)
To merge this branch: bzr merge lp:~domsense/account-financial-tools/adding_account_invoice_template
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp code review, no test Approve
Review via email: mp+144024@code.launchpad.net

Description of the change

Templates for Invoices

User can configure invoice templates, useful for recurring invoices.
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 invoice 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
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

line 178 and 180 could deserve some rewriting (too long, and abuse of Python's boolean operands IMO). I suggest:

account_obj = self.pool.get('account.account')
if type in ('out_invoice', 'out_refund'):
    taxes = product.taxes_id
else:
    taxes = product.supplier_taxes_id
if tax_ids and a:
    taxes = account_obj.browse(cr, uid, a, context=context).tax_ids
if taxes:
    taxes = [tax.id for tax in taxes]
else:
    taxes = False

which should do the same thing (not tested, needs proof reading). The last "taxes" should be renamed tax_ids for consistency.

I'm not too fond of "a" as an identifier btw. Too shord. I recommend renaming it to "accound_id" (line 165 and following)

line 182-185: is it me on a monday morning or are both branch of the test running the same code?

last point: the branch you are targetting is the one for OERP 6.1. Is this what you intended?

review: Needs Fixing (code review, no test)
100. By Lorenzo Battistini

[FIX] too long lines

101. By Lorenzo Battistini

[FIX] same code for two branches

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

2013/1/21 Alexandre Fayolle @ camptocamp <email address hidden>

> Review: Needs Fixing code review, no test
>
> line 178 and 180 could deserve some rewriting (too long, and abuse of
> Python's boolean operands IMO). I suggest:
>
>
Rewritten.

> line 182-185: is it me on a monday morning or are both branch of the test
> running the same code?
>

Uh, right. :-D

>
> last point: the branch you are targetting is the one for OERP 6.1. Is this
> what you intended?
>

Yes it is.
Module not ported to 7.0 yet.

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM after the fixes.

review: Approve (code review, no test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_invoice_template'
2=== added file 'account_invoice_template/AUTHORS.txt'
3--- account_invoice_template/AUTHORS.txt 1970-01-01 00:00:00 +0000
4+++ account_invoice_template/AUTHORS.txt 2013-01-29 21:36:21 +0000
5@@ -0,0 +1,3 @@
6+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
7+Leonardo Pistone <leonardo.pistone@agilebg.com>
8+Franco Tampieri <franco.tampieri@agilebg.com>
9
10=== added file 'account_invoice_template/__init__.py'
11--- account_invoice_template/__init__.py 1970-01-01 00:00:00 +0000
12+++ account_invoice_template/__init__.py 2013-01-29 21:36:21 +0000
13@@ -0,0 +1,22 @@
14+# -*- coding: utf-8 -*-
15+##############################################################################
16+#
17+# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
18+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
19+#
20+# This program is free software: you can redistribute it and/or modify
21+# it under the terms of the GNU Affero General Public License as published
22+# by the Free Software Foundation, either version 3 of the License, or
23+# (at your option) any later version.
24+#
25+# This program is distributed in the hope that it will be useful,
26+# but WITHOUT ANY WARRANTY; without even the implied warranty of
27+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28+# GNU Affero General Public License for more details.
29+#
30+# You should have received a copy of the GNU Affero General Public License
31+# along with this program. If not, see <http://www.gnu.org/licenses/>.
32+#
33+##############################################################################
34+import account_invoice_template
35+import wizard
36
37=== added file 'account_invoice_template/__openerp__.py'
38--- account_invoice_template/__openerp__.py 1970-01-01 00:00:00 +0000
39+++ account_invoice_template/__openerp__.py 2013-01-29 21:36:21 +0000
40@@ -0,0 +1,45 @@
41+# -*- coding: utf-8 -*-
42+##############################################################################
43+#
44+# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
45+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
46+#
47+# This program is free software: you can redistribute it and/or modify
48+# it under the terms of the GNU Affero General Public License as published
49+# by the Free Software Foundation, either version 3 of the License, or
50+# (at your option) any later version.
51+#
52+# This program is distributed in the hope that it will be useful,
53+# but WITHOUT ANY WARRANTY; without even the implied warranty of
54+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55+# GNU Affero General Public License for more details.
56+#
57+# You should have received a copy of the GNU Affero General Public License
58+# along with this program. If not, see <http://www.gnu.org/licenses/>.
59+#
60+##############################################################################
61+{
62+ 'name': "Account Invoice Template",
63+ 'version': '0.1',
64+ 'category': 'Generic Modules/Accounting',
65+ 'description': """
66+Templates for Invoices
67+
68+User can configure invoice templates, useful for recurring invoices.
69+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.
70+The invoice form allows lo load, through a wizard, the template to use and the amounts to fill.
71+""",
72+ 'author': 'Agile Business Group',
73+ 'website': 'http://www.agilebg.com',
74+ 'license': 'AGPL-3',
75+ "depends" : ['account_move_template'],
76+ "init_xml" : [],
77+ "update_xml" : [
78+ 'invoice_template.xml',
79+ 'wizard/select_template.xml',
80+ 'security/ir.model.access.csv',
81+ ],
82+ "demo_xml" : [],
83+ "active": False,
84+ "installable": True
85+}
86
87=== added file 'account_invoice_template/account_invoice_template.py'
88--- account_invoice_template/account_invoice_template.py 1970-01-01 00:00:00 +0000
89+++ account_invoice_template/account_invoice_template.py 2013-01-29 21:36:21 +0000
90@@ -0,0 +1,99 @@
91+# -*- coding: utf-8 -*-
92+##############################################################################
93+#
94+# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
95+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
96+#
97+# This program is free software: you can redistribute it and/or modify
98+# it under the terms of the GNU Affero General Public License as published
99+# by the Free Software Foundation, either version 3 of the License, or
100+# (at your option) any later version.
101+#
102+# This program is distributed in the hope that it will be useful,
103+# but WITHOUT ANY WARRANTY; without even the implied warranty of
104+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
105+# GNU Affero General Public License for more details.
106+#
107+# You should have received a copy of the GNU Affero General Public License
108+# along with this program. If not, see <http://www.gnu.org/licenses/>.
109+#
110+##############################################################################
111+
112+from openerp.osv import fields, osv
113+from openerp.tools.translate import _
114+
115+class account_invoice_template(osv.osv):
116+
117+ _inherit = 'account.document.template'
118+ _name = 'account.invoice.template'
119+
120+ _columns = {
121+ 'partner_id': fields.many2one('res.partner', 'Partner', required=True),
122+ 'account_id': fields.many2one('account.account', 'Account', required=True),
123+ 'template_line_ids': fields.one2many('account.invoice.template.line', 'template_id', 'Template Lines'),
124+ 'type': fields.selection([
125+ ('out_invoice','Customer Invoice'),
126+ ('in_invoice','Supplier Invoice'),
127+ ('out_refund','Customer Refund'),
128+ ('in_refund','Supplier Refund'),
129+ ],'Type', required=True ),
130+ }
131+
132+
133+class account_invoice_template_line(osv.osv):
134+
135+ _name = 'account.invoice.template.line'
136+ _inherit = 'account.document.template.line'
137+
138+ _columns = {
139+ 'account_id': fields.many2one('account.account', 'Account', required=True, domain=[('type','<>','view'), ('type', '<>', 'closed')]),
140+ 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account', ondelete="cascade"),
141+ 'invoice_line_tax_id': fields.many2many('account.tax', 'account_invoice_template_line_tax', 'invoice_line_id', 'tax_id', 'Taxes', domain=[('parent_id','=',False)]),
142+ 'template_id': fields.many2one('account.invoice.template', 'Template'),
143+ 'product_id': fields.many2one('product.product', 'Product'),
144+ }
145+
146+ _sql_constraints = [
147+ ('sequence_template_uniq', 'unique (template_id,sequence)', 'The sequence of the line must be unique per template !')
148+ ]
149+
150+ def product_id_change(self, cr, uid, ids, product_id, type, context=None):
151+ if context is None:
152+ context = {}
153+
154+ result = {}
155+ if not product_id:
156+ return {}
157+
158+ product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
159+
160+ # name
161+ result.update({'name': product.name})
162+
163+ # account
164+ account_id = False
165+ if type in ('out_invoice','out_refund'):
166+ account_id = product.product_tmpl_id.property_account_income.id
167+ if not account_id:
168+ account_id = product.categ_id.property_account_income_categ.id
169+ else:
170+ account_id = product.product_tmpl_id.property_account_expense.id
171+ if not account_id:
172+ account_id = product.categ_id.property_account_expense_categ.id
173+
174+ if account_id:
175+ result['account_id'] = account_id
176+
177+ # taxes
178+ account_obj = self.pool.get('account.account')
179+ taxes = account_id and account_obj.browse(
180+ cr, uid, account_id, context=context).tax_ids or False
181+ if type in ('out_invoice', 'out_refund') and product.taxes_id:
182+ taxes = product.taxes_id
183+ elif product.supplier_taxes_id:
184+ taxes = product.supplier_taxes_id
185+ tax_ids = taxes and [tax.id for tax in taxes] or False
186+ result.update({'invoice_line_tax_id': tax_ids})
187+
188+ return {'value': result}
189+
190
191=== added directory 'account_invoice_template/i18n'
192=== added file 'account_invoice_template/i18n/account_invoice_template.pot'
193--- account_invoice_template/i18n/account_invoice_template.pot 1970-01-01 00:00:00 +0000
194+++ account_invoice_template/i18n/account_invoice_template.pot 2013-01-29 21:36:21 +0000
195@@ -0,0 +1,204 @@
196+# Translation of OpenERP Server.
197+# This file contains the translation of the following modules:
198+# * account_invoice_template
199+#
200+msgid ""
201+msgstr ""
202+"Project-Id-Version: OpenERP Server 6.0.3\n"
203+"Report-Msgid-Bugs-To: support@openerp.com\n"
204+"POT-Creation-Date: 2011-10-31 16:49+0000\n"
205+"PO-Revision-Date: 2011-10-31 16:49+0000\n"
206+"Last-Translator: <>\n"
207+"Language-Team: \n"
208+"MIME-Version: 1.0\n"
209+"Content-Type: text/plain; charset=UTF-8\n"
210+"Content-Transfer-Encoding: \n"
211+"Plural-Forms: \n"
212+
213+#. module: account_invoice_template
214+#: selection:account.invoice.template,type:0
215+#: selection:wizard.select.invoice.template.line,type:0
216+msgid "Customer Refund"
217+msgstr ""
218+
219+#. module: account_invoice_template
220+#: model:ir.actions.act_window,name:account_invoice_template.action_wizard_select_template_by_invoice
221+#: model:ir.ui.menu,name:account_invoice_template.menu_action_wizard_select_template
222+msgid "Create Invoice from Template"
223+msgstr ""
224+
225+#. module: account_invoice_template
226+#: selection:account.invoice.template,type:0
227+#: selection:wizard.select.invoice.template.line,type:0
228+msgid "Customer Invoice"
229+msgstr ""
230+
231+#. module: account_invoice_template
232+#: model:ir.model,name:account_invoice_template.model_account_invoice_template_line
233+msgid "account.invoice.template.line"
234+msgstr ""
235+
236+#. module: account_invoice_template
237+#: field:account.invoice.template.line,sequence:0
238+#: field:wizard.select.invoice.template.line,sequence:0
239+msgid "Number"
240+msgstr ""
241+
242+#. module: account_invoice_template
243+#: selection:account.invoice.template,type:0
244+#: selection:wizard.select.invoice.template.line,type:0
245+msgid "Supplier Invoice"
246+msgstr ""
247+
248+#. module: account_invoice_template
249+#: field:account.invoice.template.line,template_id:0
250+#: field:wizard.select.invoice.template.line,template_id:0
251+msgid "Template"
252+msgstr ""
253+
254+#. module: account_invoice_template
255+#: field:account.invoice.template,type:0
256+#: field:account.invoice.template.line,type:0
257+#: field:wizard.select.invoice.template.line,type:0
258+msgid "Type"
259+msgstr ""
260+
261+#. module: account_invoice_template
262+#: model:ir.model,name:account_invoice_template.model_account_invoice_template
263+msgid "account.invoice.template"
264+msgstr ""
265+
266+#. module: account_invoice_template
267+#: model:ir.model,name:account_invoice_template.model_wizard_select_invoice_template
268+msgid "wizard.select.invoice.template"
269+msgstr ""
270+
271+#. module: account_invoice_template
272+#: code:addons/account_invoice_template/wizard/select_template.py:66
273+#, python-format
274+msgid "Error !"
275+msgstr ""
276+
277+#. module: account_invoice_template
278+#: selection:account.invoice.template.line,type:0
279+msgid "User input"
280+msgstr ""
281+
282+#. module: account_invoice_template
283+#: view:account.invoice.template.line:0
284+#: view:wizard.select.invoice.template.line:0
285+msgid "Invoice Template Line"
286+msgstr ""
287+
288+#. module: account_invoice_template
289+#: field:account.invoice.template,account_id:0
290+#: field:account.invoice.template.line,account_id:0
291+#: field:wizard.select.invoice.template.line,account_id:0
292+msgid "Account"
293+msgstr ""
294+
295+#. module: account_invoice_template
296+#: field:account.invoice.template,name:0
297+#: field:account.invoice.template.line,name:0
298+#: field:wizard.select.invoice.template.line,name:0
299+msgid "Name"
300+msgstr ""
301+
302+#. module: account_invoice_template
303+#: field:wizard.select.invoice.template,line_ids:0
304+msgid "Lines"
305+msgstr ""
306+
307+#. module: account_invoice_template
308+#: field:account.invoice.template.line,invoice_line_tax_id:0
309+msgid "Taxes"
310+msgstr ""
311+
312+#. module: account_invoice_template
313+#: code:addons/account_invoice_template/wizard/select_template.py:66
314+#, python-format
315+msgid "At least one amount has to be non-zero!"
316+msgstr ""
317+
318+#. module: account_invoice_template
319+#: field:wizard.select.invoice.template.line,amount:0
320+msgid "Amount"
321+msgstr ""
322+
323+#. module: account_invoice_template
324+#: view:account.invoice.template:0
325+#: view:wizard.select.invoice.template:0
326+#: field:wizard.select.invoice.template,template_id:0
327+msgid "Invoice Template"
328+msgstr ""
329+
330+#. module: account_invoice_template
331+#: selection:account.invoice.template,type:0
332+#: selection:wizard.select.invoice.template.line,type:0
333+msgid "Supplier Refund"
334+msgstr ""
335+
336+#. module: account_invoice_template
337+#: model:ir.actions.act_window,name:account_invoice_template.action_wizard_select_template
338+msgid "Select Invoice Template"
339+msgstr ""
340+
341+#. module: account_invoice_template
342+#: sql_constraint:account.invoice.template.line:0
343+msgid "The sequence of the line must be unique per template !"
344+msgstr ""
345+
346+#. module: account_invoice_template
347+#: view:wizard.select.invoice.template:0
348+msgid "Load"
349+msgstr ""
350+
351+#. module: account_invoice_template
352+#: view:account.invoice.template.line:0
353+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'"
354+msgstr ""
355+
356+#. module: account_invoice_template
357+#: selection:account.invoice.template.line,type:0
358+msgid "Computed"
359+msgstr ""
360+
361+#. module: account_invoice_template
362+#: view:account.invoice.template:0
363+msgid "Group By..."
364+msgstr ""
365+
366+#. module: account_invoice_template
367+#: view:account.invoice.template.line:0
368+#: field:account.invoice.template.line,python_code:0
369+msgid "Python Code"
370+msgstr ""
371+
372+#. module: account_invoice_template
373+#: model:ir.actions.act_window,name:account_invoice_template.action_invoice_template_form
374+#: model:ir.ui.menu,name:account_invoice_template.menu_action_invoice_template_form
375+msgid "Invoice Templates"
376+msgstr ""
377+
378+#. module: account_invoice_template
379+#: field:account.invoice.template.line,analytic_account_id:0
380+msgid "Analytic Account"
381+msgstr ""
382+
383+#. module: account_invoice_template
384+#: field:account.invoice.template,template_line_ids:0
385+#: model:ir.model,name:account_invoice_template.model_wizard_select_invoice_template_line
386+msgid "Template Lines"
387+msgstr ""
388+
389+#. module: account_invoice_template
390+#: view:wizard.select.invoice.template:0
391+msgid "Cancel"
392+msgstr ""
393+
394+#. module: account_invoice_template
395+#: view:account.invoice.template:0
396+#: field:account.invoice.template,partner_id:0
397+msgid "Partner"
398+msgstr ""
399+
400
401=== added file 'account_invoice_template/i18n/it.po'
402--- account_invoice_template/i18n/it.po 1970-01-01 00:00:00 +0000
403+++ account_invoice_template/i18n/it.po 2013-01-29 21:36:21 +0000
404@@ -0,0 +1,228 @@
405+# Translation of OpenERP Server.
406+# This file contains the translation of the following modules:
407+# * account_invoice_template
408+#
409+msgid ""
410+msgstr ""
411+"Project-Id-Version: OpenERP Server 6.0.3\n"
412+"Report-Msgid-Bugs-To: support@openerp.com\n"
413+"POT-Creation-Date: 2011-11-02 10:30+0000\n"
414+"PO-Revision-Date: 2011-11-02 11:35+0100\n"
415+"Last-Translator: Lorenzo Battistini <lorenzo.battistini@agilebg.com>\n"
416+"Language-Team: \n"
417+"MIME-Version: 1.0\n"
418+"Content-Type: text/plain; charset=UTF-8\n"
419+"Content-Transfer-Encoding: 8bit\n"
420+"Plural-Forms: \n"
421+
422+#. module: account_invoice_template
423+#: view:account.invoice.template.line:0
424+#: view:wizard.select.invoice.template.line:0
425+msgid "Invoice Template Line"
426+msgstr "Riga template fattura"
427+
428+#. module: account_invoice_template
429+#: selection:account.invoice.template,type:0
430+#: selection:wizard.select.invoice.template.line,type:0
431+msgid "Customer Refund"
432+msgstr "Nota di credito"
433+
434+#. module: account_invoice_template
435+#: model:ir.actions.act_window,name:account_invoice_template.action_wizard_select_template_by_invoice
436+#: model:ir.ui.menu,name:account_invoice_template.menu_action_wizard_select_template
437+msgid "Create Invoice from Template"
438+msgstr "Crea fattura da template"
439+
440+#. module: account_invoice_template
441+#: selection:account.invoice.template,type:0
442+#: selection:wizard.select.invoice.template.line,type:0
443+msgid "Customer Invoice"
444+msgstr "Fattura cliente"
445+
446+#. module: account_invoice_template
447+#: model:ir.model,name:account_invoice_template.model_account_invoice_template_line
448+msgid "account.invoice.template.line"
449+msgstr "account.invoice.template.line"
450+
451+#. module: account_invoice_template
452+#: field:account.invoice.template.line,sequence:0
453+#: field:wizard.select.invoice.template.line,sequence:0
454+msgid "Number"
455+msgstr "Numero"
456+
457+#. module: account_invoice_template
458+#: view:account.invoice.template:0
459+msgid "Group By..."
460+msgstr "Raggruppa per..."
461+
462+#. module: account_invoice_template
463+#: field:account.invoice.template.line,template_id:0
464+#: field:wizard.select.invoice.template.line,template_id:0
465+msgid "Template"
466+msgstr "Template"
467+
468+#. module: account_invoice_template
469+#: field:account.invoice.template,type:0
470+#: field:account.invoice.template.line,type:0
471+#: field:wizard.select.invoice.template.line,type:0
472+msgid "Type"
473+msgstr "Tipo"
474+
475+#. module: account_invoice_template
476+#: model:ir.model,name:account_invoice_template.model_account_invoice_template
477+msgid "account.invoice.template"
478+msgstr "account.invoice.template"
479+
480+#. module: account_invoice_template
481+#: model:ir.model,name:account_invoice_template.model_wizard_select_invoice_template
482+msgid "wizard.select.invoice.template"
483+msgstr "wizard.select.invoice.template"
484+
485+#. module: account_invoice_template
486+#: code:addons/account_invoice_template/wizard/select_template.py:67
487+#, python-format
488+msgid "Error !"
489+msgstr "Errore !"
490+
491+#. module: account_invoice_template
492+#: selection:account.invoice.template.line,type:0
493+msgid "User input"
494+msgstr "Input utente"
495+
496+#. module: account_invoice_template
497+#: model:ir.module.module,description:account_invoice_template.module_meta_information
498+msgid ""
499+"\n"
500+"======================\n"
501+"Templates for Invoices\n"
502+"======================\n"
503+"User can configure invoice templates, useful for recurring invoices.\n"
504+"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"
505+"The invoice form allows lo load, through a wizard, the template to use and the amounts to fill.\n"
506+msgstr ""
507+"\n"
508+"======================\n"
509+"Templates for Invoices\n"
510+"======================\n"
511+"User can configure invoice templates, useful for recurring invoices.\n"
512+"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"
513+"The invoice form allows lo load, through a wizard, the template to use and the amounts to fill.\n"
514+
515+#. module: account_invoice_template
516+#: field:account.invoice.template,account_id:0
517+#: field:account.invoice.template.line,account_id:0
518+#: field:wizard.select.invoice.template.line,account_id:0
519+msgid "Account"
520+msgstr "Conto"
521+
522+#. module: account_invoice_template
523+#: field:account.invoice.template,name:0
524+#: field:account.invoice.template.line,name:0
525+#: field:wizard.select.invoice.template.line,name:0
526+msgid "Name"
527+msgstr "Nome"
528+
529+#. module: account_invoice_template
530+#: field:wizard.select.invoice.template,line_ids:0
531+msgid "Lines"
532+msgstr "Righe"
533+
534+#. module: account_invoice_template
535+#: field:account.invoice.template.line,invoice_line_tax_id:0
536+msgid "Taxes"
537+msgstr "Imposte"
538+
539+#. module: account_invoice_template
540+#: code:addons/account_invoice_template/wizard/select_template.py:67
541+#, python-format
542+msgid "At least one amount has to be non-zero!"
543+msgstr "Almeno un importo deve essere diverso da zero!"
544+
545+#. module: account_invoice_template
546+#: field:wizard.select.invoice.template.line,amount:0
547+msgid "Amount"
548+msgstr "Importo"
549+
550+#. module: account_invoice_template
551+#: view:account.invoice.template:0
552+#: view:wizard.select.invoice.template:0
553+#: field:wizard.select.invoice.template,template_id:0
554+msgid "Invoice Template"
555+msgstr "Template fattura"
556+
557+#. module: account_invoice_template
558+#: selection:account.invoice.template,type:0
559+#: selection:wizard.select.invoice.template.line,type:0
560+msgid "Supplier Refund"
561+msgstr "Reso a fornitore"
562+
563+#. module: account_invoice_template
564+#: model:ir.actions.act_window,name:account_invoice_template.action_wizard_select_template
565+msgid "Select Invoice Template"
566+msgstr "Scegli template fattura"
567+
568+#. module: account_invoice_template
569+#: sql_constraint:account.invoice.template.line:0
570+msgid "The sequence of the line must be unique per template !"
571+msgstr "Il numero della riga deve essere unico per template!"
572+
573+#. module: account_invoice_template
574+#: model:ir.module.module,shortdesc:account_invoice_template.module_meta_information
575+msgid "Account Invoice Template"
576+msgstr "Account Invoice Template"
577+
578+#. module: account_invoice_template
579+#: view:wizard.select.invoice.template:0
580+msgid "Load"
581+msgstr "Carica"
582+
583+#. module: account_invoice_template
584+#: view:account.invoice.template.line:0
585+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'"
586+msgstr "E' possibile fare riferimento alle altre righe usando il loro numero (ad es. 'L(1)' rappresenta la prima riga). Esempi di codice: 'L(1) * 0.2'; 'L(2) - L(1)'; 'L(1) + L(2) + L(3)'; '1250'"
587+
588+#. module: account_invoice_template
589+#: selection:account.invoice.template.line,type:0
590+msgid "Computed"
591+msgstr "Calcolato"
592+
593+#. module: account_invoice_template
594+#: selection:account.invoice.template,type:0
595+#: selection:wizard.select.invoice.template.line,type:0
596+msgid "Supplier Invoice"
597+msgstr "Fattura fornitore"
598+
599+#. module: account_invoice_template
600+#: view:account.invoice.template.line:0
601+#: field:account.invoice.template.line,python_code:0
602+msgid "Python Code"
603+msgstr "Codice python"
604+
605+#. module: account_invoice_template
606+#: model:ir.actions.act_window,name:account_invoice_template.action_invoice_template_form
607+#: model:ir.ui.menu,name:account_invoice_template.menu_action_invoice_template_form
608+msgid "Invoice Templates"
609+msgstr "Template fatture"
610+
611+#. module: account_invoice_template
612+#: field:account.invoice.template.line,analytic_account_id:0
613+msgid "Analytic Account"
614+msgstr "Conto analitico"
615+
616+#. module: account_invoice_template
617+#: field:account.invoice.template,template_line_ids:0
618+#: model:ir.model,name:account_invoice_template.model_wizard_select_invoice_template_line
619+msgid "Template Lines"
620+msgstr "Righe template"
621+
622+#. module: account_invoice_template
623+#: view:wizard.select.invoice.template:0
624+msgid "Cancel"
625+msgstr "Annulla"
626+
627+#. module: account_invoice_template
628+#: view:account.invoice.template:0
629+#: field:account.invoice.template,partner_id:0
630+msgid "Partner"
631+msgstr "Partner"
632+
633
634=== added file 'account_invoice_template/invoice_template.xml'
635--- account_invoice_template/invoice_template.xml 1970-01-01 00:00:00 +0000
636+++ account_invoice_template/invoice_template.xml 2013-01-29 21:36:21 +0000
637@@ -0,0 +1,103 @@
638+<?xml version="1.0" encoding="utf-8"?>
639+<openerp>
640+ <data>
641+
642+ <record id="view_invoice_template_line_tree" model="ir.ui.view">
643+ <field name="name">account.invoice.template.line.tree</field>
644+ <field name="model">account.invoice.template.line</field>
645+ <field name="type">tree</field>
646+ <field name="arch" type="xml">
647+ <tree string="Invoice Template Line">
648+ <field name="product_id"/>
649+ <field name="sequence"/>
650+ <field name="name"/>
651+ <field name="account_id" />
652+ <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
653+ <field name="type"/>
654+ <field name="python_code"/>
655+ </tree>
656+ </field>
657+ </record>
658+
659+
660+ <record id="view_invoice_template_line_form" model="ir.ui.view">
661+ <field name="name">account.invoice.template.line.form</field>
662+ <field name="model">account.invoice.template.line</field>
663+ <field name="type">form</field>
664+ <field name="arch" type="xml">
665+ <form string="Invoice Template Line">
666+ <field name="product_id" on_change="product_id_change(product_id, parent.type)"/>
667+ <field name="name" select="1"/>
668+ <field name="sequence"/>
669+ <field name="account_id" />
670+ <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
671+ <field name="type"/>
672+ <separator string="Python Code" colspan="4"/>
673+ <field name="python_code" colspan="4" attrs="{'readonly': [('type', '!=', 'computed')]}" nolabel="1"/>
674+ <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"/>
675+ <field name="invoice_line_tax_id" colspan="4" nolabel="1"/>
676+ </form>
677+ </field>
678+ </record>
679+
680+ <record id="view_invoice_template_form" model="ir.ui.view">
681+ <field name="name">account.invoice.template.form</field>
682+ <field name="model">account.invoice.template</field>
683+ <field name="type">form</field>
684+ <field name="arch" type="xml">
685+ <form string="Invoice Template">
686+ <field name="name"/>
687+ <field name="partner_id"/>
688+ <field name="account_id" />
689+ <field name="type" />
690+ <field colspan="4" nolabel="1" name="template_line_ids"/>
691+ </form>
692+ </field>
693+ </record>
694+
695+ <record id="view_invoice_template_tree" model="ir.ui.view">
696+ <field name="name">account.invoice.template.tree</field>
697+ <field name="model">account.invoice.template</field>
698+ <field name="type">tree</field>
699+ <field name="arch" type="xml">
700+ <tree string="Invoice Template">
701+ <field name="name"/>
702+ <field name="partner_id"/>
703+ <field name="account_id" />
704+ <field name="type" />
705+ </tree>
706+ </field>
707+ </record>
708+
709+ <record id="view_invoice_template_search" model="ir.ui.view">
710+ <field name="name">account.invoice.template.search</field>
711+ <field name="model">account.invoice.template</field>
712+ <field name="type">search</field>
713+ <field name="arch" type="xml">
714+ <search string="Invoice Template">
715+ <group>
716+ <field name="name"/>
717+ <field name="partner_id" />
718+ <field name="account_id" />
719+ <field name="type" />
720+ </group>
721+ <newline/>
722+ <group expand="0" string="Group By...">
723+ <filter string="Partner" icon="terp-folder-orange" domain="[]" context="{'group_by':'partner_id'}"/>
724+ </group>
725+ </search>
726+ </field>
727+ </record>
728+
729+ <record id="action_invoice_template_form" model="ir.actions.act_window">
730+ <field name="name">Invoice Templates</field>
731+ <field name="res_model">account.invoice.template</field>
732+ <field name="view_type">form</field>
733+ <field name="view_mode">tree,form</field>
734+ <field name="search_view_id" ref="view_invoice_template_search"/>
735+ </record>
736+ <menuitem
737+ action="action_invoice_template_form" id="menu_action_invoice_template_form" sequence="5"
738+ parent="account.menu_configuration_misc" groups="base.group_extended"/>
739+ </data>
740+</openerp>
741
742=== added directory 'account_invoice_template/security'
743=== added file 'account_invoice_template/security/ir.model.access.csv'
744--- account_invoice_template/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
745+++ account_invoice_template/security/ir.model.access.csv 2013-01-29 21:36:21 +0000
746@@ -0,0 +1,5 @@
747+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
748+"access_account_invoice_template_user","account_invoice_template_user","model_account_invoice_template","account.group_account_user","1","1","1","1"
749+"access_account_invoice_template_manager","account_invoice_template_manager","model_account_invoice_template","account.group_account_manager","1","1","1","1"
750+"access_account_invoice_template_line_user","account_invoice_template_line_user","model_account_invoice_template_line","account.group_account_user","1","1","1","1"
751+"access_account_invoice_template_line_manager","account_invoice_template_line_manager","model_account_invoice_template_line","account.group_account_manager","1","1","1","1"
752
753=== added directory 'account_invoice_template/wizard'
754=== added file 'account_invoice_template/wizard/__init__.py'
755--- account_invoice_template/wizard/__init__.py 1970-01-01 00:00:00 +0000
756+++ account_invoice_template/wizard/__init__.py 2013-01-29 21:36:21 +0000
757@@ -0,0 +1,21 @@
758+# -*- coding: utf-8 -*-
759+##############################################################################
760+#
761+# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
762+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
763+#
764+# This program is free software: you can redistribute it and/or modify
765+# it under the terms of the GNU Affero General Public License as published
766+# by the Free Software Foundation, either version 3 of the License, or
767+# (at your option) any later version.
768+#
769+# This program is distributed in the hope that it will be useful,
770+# but WITHOUT ANY WARRANTY; without even the implied warranty of
771+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
772+# GNU Affero General Public License for more details.
773+#
774+# You should have received a copy of the GNU Affero General Public License
775+# along with this program. If not, see <http://www.gnu.org/licenses/>.
776+#
777+##############################################################################
778+import select_template
779
780=== added file 'account_invoice_template/wizard/select_template.py'
781--- account_invoice_template/wizard/select_template.py 1970-01-01 00:00:00 +0000
782+++ account_invoice_template/wizard/select_template.py 2013-01-29 21:36:21 +0000
783@@ -0,0 +1,133 @@
784+# -*- coding: utf-8 -*-
785+##############################################################################
786+#
787+# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
788+# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
789+#
790+# This program is free software: you can redistribute it and/or modify
791+# it under the terms of the GNU Affero General Public License as published
792+# by the Free Software Foundation, either version 3 of the License, or
793+# (at your option) any later version.
794+#
795+# This program is distributed in the hope that it will be useful,
796+# but WITHOUT ANY WARRANTY; without even the implied warranty of
797+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
798+# GNU Affero General Public License for more details.
799+#
800+# You should have received a copy of the GNU Affero General Public License
801+# along with this program. If not, see <http://www.gnu.org/licenses/>.
802+#
803+##############################################################################
804+
805+from openerp.osv import fields,osv
806+import time
807+from openerp.tools.translate import _
808+
809+class wizard_select_template(osv.osv_memory):
810+
811+ _name = "wizard.select.invoice.template"
812+ _columns = {
813+ 'template_id': fields.many2one('account.invoice.template', 'Invoice Template', required=True),
814+ 'line_ids': fields.one2many('wizard.select.invoice.template.line', 'template_id', 'Lines'),
815+ 'state': fields.selection([
816+ ('template_selected','Template selected'),
817+ ], 'State'),
818+ }
819+
820+ def load_lines(self, cr, uid, ids, context=None):
821+ wizard = self.browse(cr, uid, ids, context=context)[0]
822+ template_pool = self.pool.get('account.invoice.template')
823+ wizard_line_pool = self.pool.get('wizard.select.invoice.template.line')
824+ template = template_pool.browse(cr, uid, wizard.template_id.id)
825+ for line in template.template_line_ids:
826+ if line.type == 'input':
827+ wizard_line_pool.create(cr, uid,{
828+ 'template_id': wizard.id,
829+ 'sequence': line.sequence,
830+ 'name': line.name,
831+ 'amount': line.product_id and line.product_id.list_price or 0.0,
832+ 'account_id': line.account_id.id,
833+ 'product_id': line.product_id.id,
834+ })
835+ if not wizard.line_ids:
836+ return self.load_template(cr, uid, ids)
837+ wizard.write({'state': 'template_selected'})
838+ return True
839+
840+ def load_template(self, cr, uid, ids, context=None):
841+ template_obj = self.pool.get('account.invoice.template')
842+ template_line_obj = self.pool.get('account.invoice.template.line')
843+ account_period_obj = self.pool.get('account.period')
844+ account_invoice_obj = self.pool.get('account.invoice')
845+ account_invoice_line_obj = self.pool.get('account.invoice.line')
846+ mod_obj = self.pool.get('ir.model.data')
847+ entry = {}
848+
849+ wizard = self.browse(cr, uid, ids, context=context)[0]
850+ if not template_obj.check_zero_lines(cr, uid, wizard):
851+ raise osv.except_osv(_('Error !'), _('At least one amount has to be non-zero!'))
852+ input_lines = {}
853+ for template_line in wizard.line_ids:
854+ input_lines[template_line.sequence] = template_line.amount
855+
856+ computed_lines = template_obj.compute_lines(cr, uid, wizard.template_id.id, input_lines)
857+
858+ inv_values = account_invoice_obj.onchange_partner_id(
859+ cr, uid, ids, wizard.template_id.type, wizard.template_id.partner_id.id)['value']
860+ inv_values['partner_id'] = wizard.template_id.partner_id.id
861+ inv_values['account_id'] = wizard.template_id.account_id.id
862+ inv_values['type'] = wizard.template_id.type
863+
864+ inv_id = account_invoice_obj.create(cr, uid, inv_values)
865+ for line in wizard.template_id.template_line_ids:
866+ analytic_account_id = False
867+ if line.analytic_account_id:
868+ analytic_account_id = line.analytic_account_id.id
869+ invoice_line_tax_id = []
870+ if line.invoice_line_tax_id:
871+ tax_ids=[]
872+ for tax in line.invoice_line_tax_id:
873+ tax_ids.append(tax.id)
874+ invoice_line_tax_id.append((6,0, tax_ids))
875+ val = {
876+ 'name': line.name,
877+ 'invoice_id': inv_id,
878+ 'account_analytic_id': analytic_account_id,
879+ 'account_id': line.account_id.id,
880+ 'invoice_line_tax_id': invoice_line_tax_id,
881+ 'price_unit': computed_lines[line.sequence],
882+ 'product_id': line.product_id.id,
883+ }
884+ id_line = account_invoice_line_obj.create(cr, uid, val)
885+
886+ if wizard.template_id.type in ('out_invoice', 'out_refund'):
887+ xml_id = 'invoice_form'
888+ else:
889+ xml_id = 'invoice_supplier_form'
890+ resource_id = mod_obj.get_object_reference(cr, uid, 'account', xml_id)[1]
891+
892+ return {
893+ 'domain': "[('id','in', ["+str(inv_id)+"])]",
894+ 'name': 'Invoice',
895+ 'view_type': 'form',
896+ 'view_mode': 'form',
897+ 'res_model': 'account.invoice',
898+ 'views': [(resource_id,'form')],
899+ 'type': 'ir.actions.act_window',
900+ 'target': 'current',
901+ 'res_id': inv_id or False,
902+ }
903+
904+
905+class wizard_select_template_line(osv.osv_memory):
906+ _description = 'Template Lines'
907+ _name = "wizard.select.invoice.template.line"
908+ _columns = {
909+ 'template_id': fields.many2one('wizard.select.invoice.template', 'Template'),
910+ 'sequence': fields.integer('Number', required=True),
911+ 'name': fields.char('Name', size=64, required=True, readonly=True),
912+ 'account_id': fields.many2one('account.account', 'Account', required=True, readonly=True),
913+ 'amount': fields.float('Amount', required=True),
914+ 'product_id': fields.many2one('product.product', 'Product'),
915+ }
916+
917
918=== added file 'account_invoice_template/wizard/select_template.xml'
919--- account_invoice_template/wizard/select_template.xml 1970-01-01 00:00:00 +0000
920+++ account_invoice_template/wizard/select_template.xml 2013-01-29 21:36:21 +0000
921@@ -0,0 +1,78 @@
922+<?xml version="1.0" encoding="utf-8"?>
923+<openerp>
924+ <data>
925+
926+ <record id="wizard_select_template" model="ir.ui.view">
927+ <field name="name">Select Invoice Template</field>
928+ <field name="model">wizard.select.invoice.template</field>
929+ <field name="type">form</field>
930+ <field name="arch" type="xml">
931+ <form string="Invoice Template" >
932+ <group col="2" width="600" height="500">
933+ <group>
934+ <field name="template_id" colspan="2" attrs="{'invisible':[('state','=','template_selected')]}"/>
935+ <field name="line_ids" colspan="2" nolabel="1" attrs="{'invisible':[('state','!=','template_selected')]}"/>
936+ <field name="state" invisible="1"/>
937+ </group>
938+ <newline/>
939+ <group col="3">
940+ <button icon="gtk-cancel" special="cancel" string="Cancel" colspan="1"/>
941+ <button icon="gtk-ok" name="load_template" string="Load" type="object" colspan="1" attrs="{'invisible':[('state','!=','template_selected')]}" />
942+ <button name="load_lines" string="Next" icon="terp-gtk-go-back-rtl" type="object" colspan="1" attrs="{'invisible':[('state','=','template_selected')]}" />
943+ </group>
944+ </group>
945+ </form>
946+ </field>
947+ </record>
948+
949+ <record id="wizard_select_template_line" model="ir.ui.view">
950+ <field name="name">Select Invoice Template Line</field>
951+ <field name="model">wizard.select.invoice.template.line</field>
952+ <field name="type">form</field>
953+ <field name="arch" type="xml">
954+ <form string="Invoice Template Line">
955+ <group col="2">
956+ <field name="sequence" invisible="1"/>
957+ <field name="name" />
958+ <field name="account_id" />
959+ <field name="amount" />
960+ </group>
961+ </form>
962+ </field>
963+ </record>
964+
965+ <record id="wizard_select_template_line_tree" model="ir.ui.view">
966+ <field name="name">Select Invoice Template Line</field>
967+ <field name="model">wizard.select.invoice.template.line</field>
968+ <field name="type">tree</field>
969+ <field name="arch" type="xml">
970+ <tree string="Invoice Template Line" editable="bottom">
971+ <field name="sequence" invisible="1"/>
972+ <field name="name" />
973+ <field name="account_id" />
974+ <field name="amount" />
975+ </tree>
976+ </field>
977+ </record>
978+
979+ <record id="action_wizard_select_template" model="ir.actions.act_window">
980+ <field name="name">Select Invoice Template</field>
981+ <field name="res_model">wizard.select.invoice.template</field>
982+ <field name="view_type">form</field>
983+ <field name="view_mode">form</field>
984+ <field name="view_id" ref="wizard_select_template"/>
985+ <field name="target">new</field>
986+ </record>
987+
988+ <act_window name="Create Invoice from Template"
989+ res_model="wizard.select.invoice.template"
990+ src_model="account.invoice"
991+ view_mode="form"
992+ target="new"
993+ key2="client_action_multi"
994+ id="action_wizard_select_template_by_invoice"
995+ view_id="wizard_select_template"/>
996+
997+ <menuitem name="Create Invoice from Template" action="action_wizard_select_template" id="menu_action_wizard_select_template" sequence="10" parent="account.menu_finance_recurrent_entries"/>
998+ </data>
999+</openerp>

Subscribers

People subscribed via source and target branches