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
=== added directory 'account_invoice_template'
=== added file 'account_invoice_template/AUTHORS.txt'
--- account_invoice_template/AUTHORS.txt 1970-01-01 00:00:00 +0000
+++ account_invoice_template/AUTHORS.txt 2013-01-29 21:36:21 +0000
@@ -0,0 +1,3 @@
1Lorenzo Battistini <lorenzo.battistini@agilebg.com>
2Leonardo Pistone <leonardo.pistone@agilebg.com>
3Franco Tampieri <franco.tampieri@agilebg.com>
04
=== added file 'account_invoice_template/__init__.py'
--- account_invoice_template/__init__.py 1970-01-01 00:00:00 +0000
+++ account_invoice_template/__init__.py 2013-01-29 21:36:21 +0000
@@ -0,0 +1,22 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
5# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published
9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21import account_invoice_template
22import wizard
023
=== added file 'account_invoice_template/__openerp__.py'
--- account_invoice_template/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_invoice_template/__openerp__.py 2013-01-29 21:36:21 +0000
@@ -0,0 +1,45 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
5# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published
9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21{
22 'name': "Account Invoice Template",
23 'version': '0.1',
24 'category': 'Generic Modules/Accounting',
25 'description': """
26Templates for Invoices
27
28User can configure invoice templates, useful for recurring invoices.
29The 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.
30The invoice form allows lo load, through a wizard, the template to use and the amounts to fill.
31""",
32 'author': 'Agile Business Group',
33 'website': 'http://www.agilebg.com',
34 'license': 'AGPL-3',
35 "depends" : ['account_move_template'],
36 "init_xml" : [],
37 "update_xml" : [
38 'invoice_template.xml',
39 'wizard/select_template.xml',
40 'security/ir.model.access.csv',
41 ],
42 "demo_xml" : [],
43 "active": False,
44 "installable": True
45}
046
=== added file 'account_invoice_template/account_invoice_template.py'
--- account_invoice_template/account_invoice_template.py 1970-01-01 00:00:00 +0000
+++ account_invoice_template/account_invoice_template.py 2013-01-29 21:36:21 +0000
@@ -0,0 +1,99 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
5# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published
9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openerp.osv import fields, osv
23from openerp.tools.translate import _
24
25class account_invoice_template(osv.osv):
26
27 _inherit = 'account.document.template'
28 _name = 'account.invoice.template'
29
30 _columns = {
31 'partner_id': fields.many2one('res.partner', 'Partner', required=True),
32 'account_id': fields.many2one('account.account', 'Account', required=True),
33 'template_line_ids': fields.one2many('account.invoice.template.line', 'template_id', 'Template Lines'),
34 'type': fields.selection([
35 ('out_invoice','Customer Invoice'),
36 ('in_invoice','Supplier Invoice'),
37 ('out_refund','Customer Refund'),
38 ('in_refund','Supplier Refund'),
39 ],'Type', required=True ),
40 }
41
42
43class account_invoice_template_line(osv.osv):
44
45 _name = 'account.invoice.template.line'
46 _inherit = 'account.document.template.line'
47
48 _columns = {
49 'account_id': fields.many2one('account.account', 'Account', required=True, domain=[('type','<>','view'), ('type', '<>', 'closed')]),
50 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account', ondelete="cascade"),
51 'invoice_line_tax_id': fields.many2many('account.tax', 'account_invoice_template_line_tax', 'invoice_line_id', 'tax_id', 'Taxes', domain=[('parent_id','=',False)]),
52 'template_id': fields.many2one('account.invoice.template', 'Template'),
53 'product_id': fields.many2one('product.product', 'Product'),
54 }
55
56 _sql_constraints = [
57 ('sequence_template_uniq', 'unique (template_id,sequence)', 'The sequence of the line must be unique per template !')
58 ]
59
60 def product_id_change(self, cr, uid, ids, product_id, type, context=None):
61 if context is None:
62 context = {}
63
64 result = {}
65 if not product_id:
66 return {}
67
68 product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
69
70 # name
71 result.update({'name': product.name})
72
73 # account
74 account_id = False
75 if type in ('out_invoice','out_refund'):
76 account_id = product.product_tmpl_id.property_account_income.id
77 if not account_id:
78 account_id = product.categ_id.property_account_income_categ.id
79 else:
80 account_id = product.product_tmpl_id.property_account_expense.id
81 if not account_id:
82 account_id = product.categ_id.property_account_expense_categ.id
83
84 if account_id:
85 result['account_id'] = account_id
86
87 # taxes
88 account_obj = self.pool.get('account.account')
89 taxes = account_id and account_obj.browse(
90 cr, uid, account_id, context=context).tax_ids or False
91 if type in ('out_invoice', 'out_refund') and product.taxes_id:
92 taxes = product.taxes_id
93 elif product.supplier_taxes_id:
94 taxes = product.supplier_taxes_id
95 tax_ids = taxes and [tax.id for tax in taxes] or False
96 result.update({'invoice_line_tax_id': tax_ids})
97
98 return {'value': result}
99
0100
=== added directory 'account_invoice_template/i18n'
=== added file 'account_invoice_template/i18n/account_invoice_template.pot'
--- account_invoice_template/i18n/account_invoice_template.pot 1970-01-01 00:00:00 +0000
+++ account_invoice_template/i18n/account_invoice_template.pot 2013-01-29 21:36:21 +0000
@@ -0,0 +1,204 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * account_invoice_template
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 6.0.3\n"
8"Report-Msgid-Bugs-To: support@openerp.com\n"
9"POT-Creation-Date: 2011-10-31 16:49+0000\n"
10"PO-Revision-Date: 2011-10-31 16:49+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: account_invoice_template
19#: selection:account.invoice.template,type:0
20#: selection:wizard.select.invoice.template.line,type:0
21msgid "Customer Refund"
22msgstr ""
23
24#. module: account_invoice_template
25#: model:ir.actions.act_window,name:account_invoice_template.action_wizard_select_template_by_invoice
26#: model:ir.ui.menu,name:account_invoice_template.menu_action_wizard_select_template
27msgid "Create Invoice from Template"
28msgstr ""
29
30#. module: account_invoice_template
31#: selection:account.invoice.template,type:0
32#: selection:wizard.select.invoice.template.line,type:0
33msgid "Customer Invoice"
34msgstr ""
35
36#. module: account_invoice_template
37#: model:ir.model,name:account_invoice_template.model_account_invoice_template_line
38msgid "account.invoice.template.line"
39msgstr ""
40
41#. module: account_invoice_template
42#: field:account.invoice.template.line,sequence:0
43#: field:wizard.select.invoice.template.line,sequence:0
44msgid "Number"
45msgstr ""
46
47#. module: account_invoice_template
48#: selection:account.invoice.template,type:0
49#: selection:wizard.select.invoice.template.line,type:0
50msgid "Supplier Invoice"
51msgstr ""
52
53#. module: account_invoice_template
54#: field:account.invoice.template.line,template_id:0
55#: field:wizard.select.invoice.template.line,template_id:0
56msgid "Template"
57msgstr ""
58
59#. module: account_invoice_template
60#: field:account.invoice.template,type:0
61#: field:account.invoice.template.line,type:0
62#: field:wizard.select.invoice.template.line,type:0
63msgid "Type"
64msgstr ""
65
66#. module: account_invoice_template
67#: model:ir.model,name:account_invoice_template.model_account_invoice_template
68msgid "account.invoice.template"
69msgstr ""
70
71#. module: account_invoice_template
72#: model:ir.model,name:account_invoice_template.model_wizard_select_invoice_template
73msgid "wizard.select.invoice.template"
74msgstr ""
75
76#. module: account_invoice_template
77#: code:addons/account_invoice_template/wizard/select_template.py:66
78#, python-format
79msgid "Error !"
80msgstr ""
81
82#. module: account_invoice_template
83#: selection:account.invoice.template.line,type:0
84msgid "User input"
85msgstr ""
86
87#. module: account_invoice_template
88#: view:account.invoice.template.line:0
89#: view:wizard.select.invoice.template.line:0
90msgid "Invoice Template Line"
91msgstr ""
92
93#. module: account_invoice_template
94#: field:account.invoice.template,account_id:0
95#: field:account.invoice.template.line,account_id:0
96#: field:wizard.select.invoice.template.line,account_id:0
97msgid "Account"
98msgstr ""
99
100#. module: account_invoice_template
101#: field:account.invoice.template,name:0
102#: field:account.invoice.template.line,name:0
103#: field:wizard.select.invoice.template.line,name:0
104msgid "Name"
105msgstr ""
106
107#. module: account_invoice_template
108#: field:wizard.select.invoice.template,line_ids:0
109msgid "Lines"
110msgstr ""
111
112#. module: account_invoice_template
113#: field:account.invoice.template.line,invoice_line_tax_id:0
114msgid "Taxes"
115msgstr ""
116
117#. module: account_invoice_template
118#: code:addons/account_invoice_template/wizard/select_template.py:66
119#, python-format
120msgid "At least one amount has to be non-zero!"
121msgstr ""
122
123#. module: account_invoice_template
124#: field:wizard.select.invoice.template.line,amount:0
125msgid "Amount"
126msgstr ""
127
128#. module: account_invoice_template
129#: view:account.invoice.template:0
130#: view:wizard.select.invoice.template:0
131#: field:wizard.select.invoice.template,template_id:0
132msgid "Invoice Template"
133msgstr ""
134
135#. module: account_invoice_template
136#: selection:account.invoice.template,type:0
137#: selection:wizard.select.invoice.template.line,type:0
138msgid "Supplier Refund"
139msgstr ""
140
141#. module: account_invoice_template
142#: model:ir.actions.act_window,name:account_invoice_template.action_wizard_select_template
143msgid "Select Invoice Template"
144msgstr ""
145
146#. module: account_invoice_template
147#: sql_constraint:account.invoice.template.line:0
148msgid "The sequence of the line must be unique per template !"
149msgstr ""
150
151#. module: account_invoice_template
152#: view:wizard.select.invoice.template:0
153msgid "Load"
154msgstr ""
155
156#. module: account_invoice_template
157#: view:account.invoice.template.line:0
158msgid "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'"
159msgstr ""
160
161#. module: account_invoice_template
162#: selection:account.invoice.template.line,type:0
163msgid "Computed"
164msgstr ""
165
166#. module: account_invoice_template
167#: view:account.invoice.template:0
168msgid "Group By..."
169msgstr ""
170
171#. module: account_invoice_template
172#: view:account.invoice.template.line:0
173#: field:account.invoice.template.line,python_code:0
174msgid "Python Code"
175msgstr ""
176
177#. module: account_invoice_template
178#: model:ir.actions.act_window,name:account_invoice_template.action_invoice_template_form
179#: model:ir.ui.menu,name:account_invoice_template.menu_action_invoice_template_form
180msgid "Invoice Templates"
181msgstr ""
182
183#. module: account_invoice_template
184#: field:account.invoice.template.line,analytic_account_id:0
185msgid "Analytic Account"
186msgstr ""
187
188#. module: account_invoice_template
189#: field:account.invoice.template,template_line_ids:0
190#: model:ir.model,name:account_invoice_template.model_wizard_select_invoice_template_line
191msgid "Template Lines"
192msgstr ""
193
194#. module: account_invoice_template
195#: view:wizard.select.invoice.template:0
196msgid "Cancel"
197msgstr ""
198
199#. module: account_invoice_template
200#: view:account.invoice.template:0
201#: field:account.invoice.template,partner_id:0
202msgid "Partner"
203msgstr ""
204
0205
=== added file 'account_invoice_template/i18n/it.po'
--- account_invoice_template/i18n/it.po 1970-01-01 00:00:00 +0000
+++ account_invoice_template/i18n/it.po 2013-01-29 21:36:21 +0000
@@ -0,0 +1,228 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * account_invoice_template
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 6.0.3\n"
8"Report-Msgid-Bugs-To: support@openerp.com\n"
9"POT-Creation-Date: 2011-11-02 10:30+0000\n"
10"PO-Revision-Date: 2011-11-02 11:35+0100\n"
11"Last-Translator: Lorenzo Battistini <lorenzo.battistini@agilebg.com>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: 8bit\n"
16"Plural-Forms: \n"
17
18#. module: account_invoice_template
19#: view:account.invoice.template.line:0
20#: view:wizard.select.invoice.template.line:0
21msgid "Invoice Template Line"
22msgstr "Riga template fattura"
23
24#. module: account_invoice_template
25#: selection:account.invoice.template,type:0
26#: selection:wizard.select.invoice.template.line,type:0
27msgid "Customer Refund"
28msgstr "Nota di credito"
29
30#. module: account_invoice_template
31#: model:ir.actions.act_window,name:account_invoice_template.action_wizard_select_template_by_invoice
32#: model:ir.ui.menu,name:account_invoice_template.menu_action_wizard_select_template
33msgid "Create Invoice from Template"
34msgstr "Crea fattura da template"
35
36#. module: account_invoice_template
37#: selection:account.invoice.template,type:0
38#: selection:wizard.select.invoice.template.line,type:0
39msgid "Customer Invoice"
40msgstr "Fattura cliente"
41
42#. module: account_invoice_template
43#: model:ir.model,name:account_invoice_template.model_account_invoice_template_line
44msgid "account.invoice.template.line"
45msgstr "account.invoice.template.line"
46
47#. module: account_invoice_template
48#: field:account.invoice.template.line,sequence:0
49#: field:wizard.select.invoice.template.line,sequence:0
50msgid "Number"
51msgstr "Numero"
52
53#. module: account_invoice_template
54#: view:account.invoice.template:0
55msgid "Group By..."
56msgstr "Raggruppa per..."
57
58#. module: account_invoice_template
59#: field:account.invoice.template.line,template_id:0
60#: field:wizard.select.invoice.template.line,template_id:0
61msgid "Template"
62msgstr "Template"
63
64#. module: account_invoice_template
65#: field:account.invoice.template,type:0
66#: field:account.invoice.template.line,type:0
67#: field:wizard.select.invoice.template.line,type:0
68msgid "Type"
69msgstr "Tipo"
70
71#. module: account_invoice_template
72#: model:ir.model,name:account_invoice_template.model_account_invoice_template
73msgid "account.invoice.template"
74msgstr "account.invoice.template"
75
76#. module: account_invoice_template
77#: model:ir.model,name:account_invoice_template.model_wizard_select_invoice_template
78msgid "wizard.select.invoice.template"
79msgstr "wizard.select.invoice.template"
80
81#. module: account_invoice_template
82#: code:addons/account_invoice_template/wizard/select_template.py:67
83#, python-format
84msgid "Error !"
85msgstr "Errore !"
86
87#. module: account_invoice_template
88#: selection:account.invoice.template.line,type:0
89msgid "User input"
90msgstr "Input utente"
91
92#. module: account_invoice_template
93#: model:ir.module.module,description:account_invoice_template.module_meta_information
94msgid ""
95"\n"
96"======================\n"
97"Templates for Invoices\n"
98"======================\n"
99"User can configure invoice templates, useful for recurring invoices.\n"
100"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"
101"The invoice form allows lo load, through a wizard, the template to use and the amounts to fill.\n"
102msgstr ""
103"\n"
104"======================\n"
105"Templates for Invoices\n"
106"======================\n"
107"User can configure invoice templates, useful for recurring invoices.\n"
108"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"
109"The invoice form allows lo load, through a wizard, the template to use and the amounts to fill.\n"
110
111#. module: account_invoice_template
112#: field:account.invoice.template,account_id:0
113#: field:account.invoice.template.line,account_id:0
114#: field:wizard.select.invoice.template.line,account_id:0
115msgid "Account"
116msgstr "Conto"
117
118#. module: account_invoice_template
119#: field:account.invoice.template,name:0
120#: field:account.invoice.template.line,name:0
121#: field:wizard.select.invoice.template.line,name:0
122msgid "Name"
123msgstr "Nome"
124
125#. module: account_invoice_template
126#: field:wizard.select.invoice.template,line_ids:0
127msgid "Lines"
128msgstr "Righe"
129
130#. module: account_invoice_template
131#: field:account.invoice.template.line,invoice_line_tax_id:0
132msgid "Taxes"
133msgstr "Imposte"
134
135#. module: account_invoice_template
136#: code:addons/account_invoice_template/wizard/select_template.py:67
137#, python-format
138msgid "At least one amount has to be non-zero!"
139msgstr "Almeno un importo deve essere diverso da zero!"
140
141#. module: account_invoice_template
142#: field:wizard.select.invoice.template.line,amount:0
143msgid "Amount"
144msgstr "Importo"
145
146#. module: account_invoice_template
147#: view:account.invoice.template:0
148#: view:wizard.select.invoice.template:0
149#: field:wizard.select.invoice.template,template_id:0
150msgid "Invoice Template"
151msgstr "Template fattura"
152
153#. module: account_invoice_template
154#: selection:account.invoice.template,type:0
155#: selection:wizard.select.invoice.template.line,type:0
156msgid "Supplier Refund"
157msgstr "Reso a fornitore"
158
159#. module: account_invoice_template
160#: model:ir.actions.act_window,name:account_invoice_template.action_wizard_select_template
161msgid "Select Invoice Template"
162msgstr "Scegli template fattura"
163
164#. module: account_invoice_template
165#: sql_constraint:account.invoice.template.line:0
166msgid "The sequence of the line must be unique per template !"
167msgstr "Il numero della riga deve essere unico per template!"
168
169#. module: account_invoice_template
170#: model:ir.module.module,shortdesc:account_invoice_template.module_meta_information
171msgid "Account Invoice Template"
172msgstr "Account Invoice Template"
173
174#. module: account_invoice_template
175#: view:wizard.select.invoice.template:0
176msgid "Load"
177msgstr "Carica"
178
179#. module: account_invoice_template
180#: view:account.invoice.template.line:0
181msgid "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'"
182msgstr "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'"
183
184#. module: account_invoice_template
185#: selection:account.invoice.template.line,type:0
186msgid "Computed"
187msgstr "Calcolato"
188
189#. module: account_invoice_template
190#: selection:account.invoice.template,type:0
191#: selection:wizard.select.invoice.template.line,type:0
192msgid "Supplier Invoice"
193msgstr "Fattura fornitore"
194
195#. module: account_invoice_template
196#: view:account.invoice.template.line:0
197#: field:account.invoice.template.line,python_code:0
198msgid "Python Code"
199msgstr "Codice python"
200
201#. module: account_invoice_template
202#: model:ir.actions.act_window,name:account_invoice_template.action_invoice_template_form
203#: model:ir.ui.menu,name:account_invoice_template.menu_action_invoice_template_form
204msgid "Invoice Templates"
205msgstr "Template fatture"
206
207#. module: account_invoice_template
208#: field:account.invoice.template.line,analytic_account_id:0
209msgid "Analytic Account"
210msgstr "Conto analitico"
211
212#. module: account_invoice_template
213#: field:account.invoice.template,template_line_ids:0
214#: model:ir.model,name:account_invoice_template.model_wizard_select_invoice_template_line
215msgid "Template Lines"
216msgstr "Righe template"
217
218#. module: account_invoice_template
219#: view:wizard.select.invoice.template:0
220msgid "Cancel"
221msgstr "Annulla"
222
223#. module: account_invoice_template
224#: view:account.invoice.template:0
225#: field:account.invoice.template,partner_id:0
226msgid "Partner"
227msgstr "Partner"
228
0229
=== added file 'account_invoice_template/invoice_template.xml'
--- account_invoice_template/invoice_template.xml 1970-01-01 00:00:00 +0000
+++ account_invoice_template/invoice_template.xml 2013-01-29 21:36:21 +0000
@@ -0,0 +1,103 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="view_invoice_template_line_tree" model="ir.ui.view">
6 <field name="name">account.invoice.template.line.tree</field>
7 <field name="model">account.invoice.template.line</field>
8 <field name="type">tree</field>
9 <field name="arch" type="xml">
10 <tree string="Invoice Template Line">
11 <field name="product_id"/>
12 <field name="sequence"/>
13 <field name="name"/>
14 <field name="account_id" />
15 <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
16 <field name="type"/>
17 <field name="python_code"/>
18 </tree>
19 </field>
20 </record>
21
22
23 <record id="view_invoice_template_line_form" model="ir.ui.view">
24 <field name="name">account.invoice.template.line.form</field>
25 <field name="model">account.invoice.template.line</field>
26 <field name="type">form</field>
27 <field name="arch" type="xml">
28 <form string="Invoice Template Line">
29 <field name="product_id" on_change="product_id_change(product_id, parent.type)"/>
30 <field name="name" select="1"/>
31 <field name="sequence"/>
32 <field name="account_id" />
33 <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
34 <field name="type"/>
35 <separator string="Python Code" colspan="4"/>
36 <field name="python_code" colspan="4" attrs="{'readonly': [('type', '!=', 'computed')]}" nolabel="1"/>
37 <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"/>
38 <field name="invoice_line_tax_id" colspan="4" nolabel="1"/>
39 </form>
40 </field>
41 </record>
42
43 <record id="view_invoice_template_form" model="ir.ui.view">
44 <field name="name">account.invoice.template.form</field>
45 <field name="model">account.invoice.template</field>
46 <field name="type">form</field>
47 <field name="arch" type="xml">
48 <form string="Invoice Template">
49 <field name="name"/>
50 <field name="partner_id"/>
51 <field name="account_id" />
52 <field name="type" />
53 <field colspan="4" nolabel="1" name="template_line_ids"/>
54 </form>
55 </field>
56 </record>
57
58 <record id="view_invoice_template_tree" model="ir.ui.view">
59 <field name="name">account.invoice.template.tree</field>
60 <field name="model">account.invoice.template</field>
61 <field name="type">tree</field>
62 <field name="arch" type="xml">
63 <tree string="Invoice Template">
64 <field name="name"/>
65 <field name="partner_id"/>
66 <field name="account_id" />
67 <field name="type" />
68 </tree>
69 </field>
70 </record>
71
72 <record id="view_invoice_template_search" model="ir.ui.view">
73 <field name="name">account.invoice.template.search</field>
74 <field name="model">account.invoice.template</field>
75 <field name="type">search</field>
76 <field name="arch" type="xml">
77 <search string="Invoice Template">
78 <group>
79 <field name="name"/>
80 <field name="partner_id" />
81 <field name="account_id" />
82 <field name="type" />
83 </group>
84 <newline/>
85 <group expand="0" string="Group By...">
86 <filter string="Partner" icon="terp-folder-orange" domain="[]" context="{'group_by':'partner_id'}"/>
87 </group>
88 </search>
89 </field>
90 </record>
91
92 <record id="action_invoice_template_form" model="ir.actions.act_window">
93 <field name="name">Invoice Templates</field>
94 <field name="res_model">account.invoice.template</field>
95 <field name="view_type">form</field>
96 <field name="view_mode">tree,form</field>
97 <field name="search_view_id" ref="view_invoice_template_search"/>
98 </record>
99 <menuitem
100 action="action_invoice_template_form" id="menu_action_invoice_template_form" sequence="5"
101 parent="account.menu_configuration_misc" groups="base.group_extended"/>
102 </data>
103</openerp>
0104
=== added directory 'account_invoice_template/security'
=== added file 'account_invoice_template/security/ir.model.access.csv'
--- account_invoice_template/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
+++ account_invoice_template/security/ir.model.access.csv 2013-01-29 21:36:21 +0000
@@ -0,0 +1,5 @@
1"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
2"access_account_invoice_template_user","account_invoice_template_user","model_account_invoice_template","account.group_account_user","1","1","1","1"
3"access_account_invoice_template_manager","account_invoice_template_manager","model_account_invoice_template","account.group_account_manager","1","1","1","1"
4"access_account_invoice_template_line_user","account_invoice_template_line_user","model_account_invoice_template_line","account.group_account_user","1","1","1","1"
5"access_account_invoice_template_line_manager","account_invoice_template_line_manager","model_account_invoice_template_line","account.group_account_manager","1","1","1","1"
06
=== added directory 'account_invoice_template/wizard'
=== added file 'account_invoice_template/wizard/__init__.py'
--- account_invoice_template/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ account_invoice_template/wizard/__init__.py 2013-01-29 21:36:21 +0000
@@ -0,0 +1,21 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
5# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published
9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21import select_template
022
=== added file 'account_invoice_template/wizard/select_template.py'
--- account_invoice_template/wizard/select_template.py 1970-01-01 00:00:00 +0000
+++ account_invoice_template/wizard/select_template.py 2013-01-29 21:36:21 +0000
@@ -0,0 +1,133 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
5# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published
9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openerp.osv import fields,osv
23import time
24from openerp.tools.translate import _
25
26class wizard_select_template(osv.osv_memory):
27
28 _name = "wizard.select.invoice.template"
29 _columns = {
30 'template_id': fields.many2one('account.invoice.template', 'Invoice Template', required=True),
31 'line_ids': fields.one2many('wizard.select.invoice.template.line', 'template_id', 'Lines'),
32 'state': fields.selection([
33 ('template_selected','Template selected'),
34 ], 'State'),
35 }
36
37 def load_lines(self, cr, uid, ids, context=None):
38 wizard = self.browse(cr, uid, ids, context=context)[0]
39 template_pool = self.pool.get('account.invoice.template')
40 wizard_line_pool = self.pool.get('wizard.select.invoice.template.line')
41 template = template_pool.browse(cr, uid, wizard.template_id.id)
42 for line in template.template_line_ids:
43 if line.type == 'input':
44 wizard_line_pool.create(cr, uid,{
45 'template_id': wizard.id,
46 'sequence': line.sequence,
47 'name': line.name,
48 'amount': line.product_id and line.product_id.list_price or 0.0,
49 'account_id': line.account_id.id,
50 'product_id': line.product_id.id,
51 })
52 if not wizard.line_ids:
53 return self.load_template(cr, uid, ids)
54 wizard.write({'state': 'template_selected'})
55 return True
56
57 def load_template(self, cr, uid, ids, context=None):
58 template_obj = self.pool.get('account.invoice.template')
59 template_line_obj = self.pool.get('account.invoice.template.line')
60 account_period_obj = self.pool.get('account.period')
61 account_invoice_obj = self.pool.get('account.invoice')
62 account_invoice_line_obj = self.pool.get('account.invoice.line')
63 mod_obj = self.pool.get('ir.model.data')
64 entry = {}
65
66 wizard = self.browse(cr, uid, ids, context=context)[0]
67 if not template_obj.check_zero_lines(cr, uid, wizard):
68 raise osv.except_osv(_('Error !'), _('At least one amount has to be non-zero!'))
69 input_lines = {}
70 for template_line in wizard.line_ids:
71 input_lines[template_line.sequence] = template_line.amount
72
73 computed_lines = template_obj.compute_lines(cr, uid, wizard.template_id.id, input_lines)
74
75 inv_values = account_invoice_obj.onchange_partner_id(
76 cr, uid, ids, wizard.template_id.type, wizard.template_id.partner_id.id)['value']
77 inv_values['partner_id'] = wizard.template_id.partner_id.id
78 inv_values['account_id'] = wizard.template_id.account_id.id
79 inv_values['type'] = wizard.template_id.type
80
81 inv_id = account_invoice_obj.create(cr, uid, inv_values)
82 for line in wizard.template_id.template_line_ids:
83 analytic_account_id = False
84 if line.analytic_account_id:
85 analytic_account_id = line.analytic_account_id.id
86 invoice_line_tax_id = []
87 if line.invoice_line_tax_id:
88 tax_ids=[]
89 for tax in line.invoice_line_tax_id:
90 tax_ids.append(tax.id)
91 invoice_line_tax_id.append((6,0, tax_ids))
92 val = {
93 'name': line.name,
94 'invoice_id': inv_id,
95 'account_analytic_id': analytic_account_id,
96 'account_id': line.account_id.id,
97 'invoice_line_tax_id': invoice_line_tax_id,
98 'price_unit': computed_lines[line.sequence],
99 'product_id': line.product_id.id,
100 }
101 id_line = account_invoice_line_obj.create(cr, uid, val)
102
103 if wizard.template_id.type in ('out_invoice', 'out_refund'):
104 xml_id = 'invoice_form'
105 else:
106 xml_id = 'invoice_supplier_form'
107 resource_id = mod_obj.get_object_reference(cr, uid, 'account', xml_id)[1]
108
109 return {
110 'domain': "[('id','in', ["+str(inv_id)+"])]",
111 'name': 'Invoice',
112 'view_type': 'form',
113 'view_mode': 'form',
114 'res_model': 'account.invoice',
115 'views': [(resource_id,'form')],
116 'type': 'ir.actions.act_window',
117 'target': 'current',
118 'res_id': inv_id or False,
119 }
120
121
122class wizard_select_template_line(osv.osv_memory):
123 _description = 'Template Lines'
124 _name = "wizard.select.invoice.template.line"
125 _columns = {
126 'template_id': fields.many2one('wizard.select.invoice.template', 'Template'),
127 'sequence': fields.integer('Number', required=True),
128 'name': fields.char('Name', size=64, required=True, readonly=True),
129 'account_id': fields.many2one('account.account', 'Account', required=True, readonly=True),
130 'amount': fields.float('Amount', required=True),
131 'product_id': fields.many2one('product.product', 'Product'),
132 }
133
0134
=== added file 'account_invoice_template/wizard/select_template.xml'
--- account_invoice_template/wizard/select_template.xml 1970-01-01 00:00:00 +0000
+++ account_invoice_template/wizard/select_template.xml 2013-01-29 21:36:21 +0000
@@ -0,0 +1,78 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="wizard_select_template" model="ir.ui.view">
6 <field name="name">Select Invoice Template</field>
7 <field name="model">wizard.select.invoice.template</field>
8 <field name="type">form</field>
9 <field name="arch" type="xml">
10 <form string="Invoice Template" >
11 <group col="2" width="600" height="500">
12 <group>
13 <field name="template_id" colspan="2" attrs="{'invisible':[('state','=','template_selected')]}"/>
14 <field name="line_ids" colspan="2" nolabel="1" attrs="{'invisible':[('state','!=','template_selected')]}"/>
15 <field name="state" invisible="1"/>
16 </group>
17 <newline/>
18 <group col="3">
19 <button icon="gtk-cancel" special="cancel" string="Cancel" colspan="1"/>
20 <button icon="gtk-ok" name="load_template" string="Load" type="object" colspan="1" attrs="{'invisible':[('state','!=','template_selected')]}" />
21 <button name="load_lines" string="Next" icon="terp-gtk-go-back-rtl" type="object" colspan="1" attrs="{'invisible':[('state','=','template_selected')]}" />
22 </group>
23 </group>
24 </form>
25 </field>
26 </record>
27
28 <record id="wizard_select_template_line" model="ir.ui.view">
29 <field name="name">Select Invoice Template Line</field>
30 <field name="model">wizard.select.invoice.template.line</field>
31 <field name="type">form</field>
32 <field name="arch" type="xml">
33 <form string="Invoice Template Line">
34 <group col="2">
35 <field name="sequence" invisible="1"/>
36 <field name="name" />
37 <field name="account_id" />
38 <field name="amount" />
39 </group>
40 </form>
41 </field>
42 </record>
43
44 <record id="wizard_select_template_line_tree" model="ir.ui.view">
45 <field name="name">Select Invoice Template Line</field>
46 <field name="model">wizard.select.invoice.template.line</field>
47 <field name="type">tree</field>
48 <field name="arch" type="xml">
49 <tree string="Invoice Template Line" editable="bottom">
50 <field name="sequence" invisible="1"/>
51 <field name="name" />
52 <field name="account_id" />
53 <field name="amount" />
54 </tree>
55 </field>
56 </record>
57
58 <record id="action_wizard_select_template" model="ir.actions.act_window">
59 <field name="name">Select Invoice Template</field>
60 <field name="res_model">wizard.select.invoice.template</field>
61 <field name="view_type">form</field>
62 <field name="view_mode">form</field>
63 <field name="view_id" ref="wizard_select_template"/>
64 <field name="target">new</field>
65 </record>
66
67 <act_window name="Create Invoice from Template"
68 res_model="wizard.select.invoice.template"
69 src_model="account.invoice"
70 view_mode="form"
71 target="new"
72 key2="client_action_multi"
73 id="action_wizard_select_template_by_invoice"
74 view_id="wizard_select_template"/>
75
76 <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"/>
77 </data>
78</openerp>

Subscribers

People subscribed via source and target branches