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

Proposed by bruno bottacini on 2013-06-18
Status: Rejected
Rejected by: Maxime Chambreuil (http://www.savoirfairelinux.com) on 2013-12-01
Proposed branch: lp:~bruno-bottacini/account-financial-tools/7.0-add_account_invoice_template
Merge into: lp:~account-core-editors/account-financial-tools/7.0
Diff against target: 1020 lines (+962/-0)
11 files modified
account_invoice_template/AUTHORS.txt (+3/-0)
account_invoice_template/__init__.py (+22/-0)
account_invoice_template/__openerp__.py (+46/-0)
account_invoice_template/account_invoice_template.py (+106/-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 (+98/-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 (+154/-0)
account_invoice_template/wizard/select_template.xml (+75/-0)
To merge this branch: bzr merge lp:~bruno-bottacini/account-financial-tools/7.0-add_account_invoice_template
Reviewer Review Type Date Requested Status
Lorenzo Battistini (community) Disapprove on 2013-11-11
Guewen Baconnier @ Camptocamp Disapprove on 2013-11-11
Maxime Chambreuil (http://www.savoirfairelinux.com) Needs Fixing on 2013-11-03
Pedro Manuel Baeza code review, no test 2013-06-18 Needs Information on 2013-10-31
Review via email: mp+170010@code.launchpad.net

Description of the change

account_invoice_template migration to openerp 7.0

To post a comment you must log in.
115. By bruno bottacini on 2013-06-18

fix bug on journal_id when not a sale invoice

Lorenzo Battistini (elbati) wrote :

Ciao Bruno,
I found some problems with context propagation.

See the following patch

=== modified file 'account_invoice_template/wizard/select_template.py'
--- account_invoice_template/wizard/select_template.py 2013-06-18 13:59:38 +0000
+++ account_invoice_template/wizard/select_template.py 2013-07-09 07:52:54 +0000
@@ -40,7 +40,7 @@
         wizard_line_pool = self.pool.get('wizard.select.invoice.template.line')
         model_data_obj = self.pool.get('ir.model.data')

- template = template_pool.browse(cr, uid, wizard.template_id.id)
+ template = template_pool.browse(cr, uid, wizard.template_id.id, context=context)
         for line in template.template_line_ids:
             if line.type == 'input':
                 wizard_line_pool.create(cr, uid,{
@@ -50,10 +50,10 @@
                     'amount': line.product_id and line.product_id.list_price or 0.0,
                     'account_id': line.account_id.id,
                     'product_id': line.product_id.id,
- })
+ }, context=context)
         if not wizard.line_ids:
- return self.load_template(cr, uid, ids)
- wizard.write({'state': 'template_selected'})
+ return self.load_template(cr, uid, ids, context=context)
+ wizard.write({'state': 'template_selected'}, context=context)

         view_rec = model_data_obj.get_object_reference(cr, uid, 'account_invoice_template', 'wizard_select_template')
         view_id = view_rec and view_rec[1] or False
@@ -70,6 +70,8 @@
         }

     def load_template(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
         template_obj = self.pool.get('account.invoice.template')
         template_line_obj = self.pool.get('account.invoice.template.line')
         account_period_obj = self.pool.get('account.period')
@@ -92,8 +94,8 @@
         inv_values['partner_id'] = wizard.template_id.partner_id.id
         inv_values['account_id'] = wizard.template_id.account_id.id
         inv_values['type'] = wizard.template_id.type
-
- inv_id = account_invoice_obj.create(cr, uid, inv_values, context={'type':wizard.template_id.type})
+ context['type'] = wizard.template_id.type
+ inv_id = account_invoice_obj.create(cr, uid, inv_values, context=context)
         for line in wizard.template_id.template_line_ids:
             analytic_account_id = False
             if line.analytic_account_id:
@@ -113,7 +115,7 @@
                 'price_unit': computed_lines[line.sequence],
                 'product_id': line.product_id.id,
             }
- id_line = account_invoice_line_obj.create(cr, uid, val)
+ id_line = account_invoice_line_obj.create(cr, uid, val, context=context)

         if wizard.template_id.type in ('out_invoice', 'out_refund'):
             xml_id = 'invoice_form'

review: Needs Fixing
116. By bruno bottacini on 2013-10-31

merge

review: Approve
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Bruno, very good contribution! However, I see this module more appropriate for account-invoicing repository, don't you think? If it's so, you can resubmit the branch to that repository.

Functionally speaking, I miss quantity and discount fields on template. Why is that?

Regards.

review: Needs Information (code review, no test)

Thanks Bruno,

I agree with Pedro. This module would better fit in the lp:account-invoicing project.

review: Needs Fixing

My review is 'Disapprove' not to blame the proposal, but because I agree with Pedro and Maxime, it would be better to propose it in lp:account-invoicing.

review: Disapprove

Unmerged revisions

116. By bruno bottacini on 2013-10-31

merge

115. By bruno bottacini on 2013-06-18

fix bug on journal_id when not a sale invoice

114. By bruno bottacini on 2013-06-18

migrate account_invoice_template to openerp 7.0

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

Subscribers

People subscribed via source and target branches