Merge lp:~openobject-italia-core-devs/openobject-italia/add_account_invoice_entry_date into lp:~openobject-italia-core-devs/openobject-italia/italian-addons

Proposed by Lorenzo Battistini
Status: Merged
Merged at revision: 126
Proposed branch: lp:~openobject-italia-core-devs/openobject-italia/add_account_invoice_entry_date
Merge into: lp:~openobject-italia-core-devs/openobject-italia/italian-addons
Diff against target: 315 lines (+284/-0)
6 files modified
account_invoice_entry_date/AUTHORS.txt (+1/-0)
account_invoice_entry_date/__init__.py (+22/-0)
account_invoice_entry_date/__openerp__.py (+36/-0)
account_invoice_entry_date/i18n/it.po (+109/-0)
account_invoice_entry_date/invoice.py (+77/-0)
account_invoice_entry_date/invoice_view.xml (+39/-0)
To merge this branch: bzr merge lp:~openobject-italia-core-devs/openobject-italia/add_account_invoice_entry_date
Reviewer Review Type Date Requested Status
Lorenzo Battistini Approve
Review via email: mp+74888@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Lorenzo Battistini (elbati) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_invoice_entry_date'
2=== added file 'account_invoice_entry_date/AUTHORS.txt'
3--- account_invoice_entry_date/AUTHORS.txt 1970-01-01 00:00:00 +0000
4+++ account_invoice_entry_date/AUTHORS.txt 2011-09-10 17:22:22 +0000
5@@ -0,0 +1,1 @@
6+Paolo Chiara <p.chiara@isa.it>
7
8=== added file 'account_invoice_entry_date/__init__.py'
9--- account_invoice_entry_date/__init__.py 1970-01-01 00:00:00 +0000
10+++ account_invoice_entry_date/__init__.py 2011-09-10 17:22:22 +0000
11@@ -0,0 +1,22 @@
12+# -*- encoding: utf-8 -*-
13+##############################################################################
14+#
15+# OpenERP, Open Source Management Solution
16+# Copyright (C) 2011 ISA s.r.l. (<http://www.isa.it>).
17+#
18+# This program is free software: you can redistribute it and/or modify
19+# it under the terms of the GNU Affero General Public License as
20+# published by the Free Software Foundation, either version 3 of the
21+# License, or (at your option) any later version.
22+#
23+# This program is distributed in the hope that it will be useful,
24+# but WITHOUT ANY WARRANTY; without even the implied warranty of
25+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26+# GNU Affero General Public License for more details.
27+#
28+# You should have received a copy of the GNU Affero General Public License
29+# along with this program. If not, see <http://www.gnu.org/licenses/>.
30+#
31+##############################################################################
32+
33+import invoice
34
35=== added file 'account_invoice_entry_date/__openerp__.py'
36--- account_invoice_entry_date/__openerp__.py 1970-01-01 00:00:00 +0000
37+++ account_invoice_entry_date/__openerp__.py 2011-09-10 17:22:22 +0000
38@@ -0,0 +1,36 @@
39+# -*- encoding: utf-8 -*-
40+##############################################################################
41+#
42+# OpenERP, Open Source Management Solution
43+# Copyright (C) 2011 Associazione OpenERP Italia
44+# http://www.openerp-italia.org>
45+#
46+# This program is free software: you can redistribute it and/or modify
47+# it under the terms of the GNU Affero General Public License as
48+# published by the Free Software Foundation, either version 3 of the
49+# License, or (at your option) any later version.
50+#
51+# This program is distributed in the hope that it will be useful,
52+# but WITHOUT ANY WARRANTY; without even the implied warranty of
53+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54+# GNU Affero General Public License for more details.
55+#
56+# You should have received a copy of the GNU Affero General Public License
57+# along with this program. If not, see <http://www.gnu.org/licenses/>.
58+#
59+##############################################################################
60+{
61+ 'name': 'Account Invoice entry Date',
62+ 'version': '0.1',
63+ 'category': 'Generic Modules/Accounting',
64+ 'description': """Account Invoice entry Date""",
65+ 'author': 'OpenERP Italian Community',
66+ 'website': 'http://www.openerp-italia.org',
67+ 'license': 'AGPL-3',
68+ "depends" : ['account',],
69+ "init_xml" : [],
70+ "update_xml" : ['invoice_view.xml'],
71+ "demo_xml" : [],
72+ "active": False,
73+ "installable": True
74+}
75
76=== added directory 'account_invoice_entry_date/i18n'
77=== added file 'account_invoice_entry_date/i18n/it.po'
78--- account_invoice_entry_date/i18n/it.po 1970-01-01 00:00:00 +0000
79+++ account_invoice_entry_date/i18n/it.po 2011-09-10 17:22:22 +0000
80@@ -0,0 +1,109 @@
81+# Translation of OpenERP Server.
82+# This file contains the translation of the following modules:
83+# * account_invoice_entry_date
84+#
85+msgid ""
86+msgstr ""
87+"Project-Id-Version: OpenERP Server 6.0.2\n"
88+"Report-Msgid-Bugs-To: support@openerp.com\n"
89+"POT-Creation-Date: 2011-09-05 10:31+0000\n"
90+"PO-Revision-Date: 2011-09-05 10:31+0000\n"
91+"Last-Translator: <>\n"
92+"Language-Team: \n"
93+"MIME-Version: 1.0\n"
94+"Content-Type: text/plain; charset=UTF-8\n"
95+"Content-Transfer-Encoding: \n"
96+"Plural-Forms: \n"
97+
98+#. module: account_invoice_entry_date
99+#: code:addons/account_invoice_entry_date/invoice.py:163
100+#, python-format
101+msgid "UserError"
102+msgstr "UserError"
103+
104+#. module: account_invoice_entry_date
105+#: code:addons/account_invoice_entry_date/invoice.py:40
106+#: code:addons/account_invoice_entry_date/invoice.py:81
107+#, python-format
108+msgid "Error !"
109+msgstr "Errore !"
110+
111+#. module: account_invoice_entry_date
112+#: code:addons/account_invoice_entry_date/invoice.py:70
113+#, python-format
114+msgid "Please verify the price of the invoice !\n"
115+"The real total does not match the computed total."
116+msgstr "Per favore verificare il prezzo della fattura!\n"
117+"Il totale reale non corrisponde al totale calcolato."
118+
119+#. module: account_invoice_entry_date
120+#: code:addons/account_invoice_entry_date/invoice.py:81
121+#, python-format
122+msgid "Cannot create the invoice !\n"
123+"The payment term defined gives a computed amount greater than the total invoiced amount."
124+msgstr "Impossibile creare la fattura!\n"
125+"I termini di pagamento definiti generano un importo calcolato maggiore del totale importo fatturato."
126+
127+#. module: account_invoice_entry_date
128+#: model:ir.module.module,description:account_invoice_entry_date.module_meta_information
129+#: model:ir.module.module,shortdesc:account_invoice_entry_date.module_meta_information
130+msgid "Account Invoice entry Date"
131+msgstr "Account Invoice entry Date"
132+
133+#. module: account_invoice_entry_date
134+#: help:account.invoice,registration_date:0
135+msgid "Keep empty to use the current date"
136+msgstr "Lasciare vuoto per utilizzare la data corrente"
137+
138+#. module: account_invoice_entry_date
139+#: code:addons/account_invoice_entry_date/invoice.py:42
140+#, python-format
141+msgid "Please create some invoice lines."
142+msgstr "Creare voci della fattura."
143+
144+#. module: account_invoice_entry_date
145+#: code:addons/account_invoice_entry_date/invoice.py:40
146+#, python-format
147+msgid "Please define sequence on invoice journal"
148+msgstr "Definire una sequenza per il giornale fatture"
149+
150+#. module: account_invoice_entry_date
151+#: code:addons/account_invoice_entry_date/invoice.py:70
152+#, python-format
153+msgid "Bad total !"
154+msgstr "Totale Errato !"
155+
156+#. module: account_invoice_entry_date
157+#: code:addons/account_invoice_entry_date/invoice.py:57
158+#, python-format
159+msgid "The invoice date cannot be later than the date of registration!"
160+msgstr "La data di fatturazione non può essere successiva alla data di registrazione!"
161+
162+#. module: account_invoice_entry_date
163+#: model:ir.model,name:account_invoice_entry_date.model_account_invoice
164+msgid "Invoice"
165+msgstr "Fattura"
166+
167+#. module: account_invoice_entry_date
168+#: code:addons/account_invoice_entry_date/invoice.py:164
169+#, python-format
170+msgid "Cannot create invoice move on centralised journal"
171+msgstr "Impossibile creare la registrazione della fattura su un giornale centralizzato"
172+
173+#. module: account_invoice_entry_date
174+#: code:addons/account_invoice_entry_date/invoice.py:42
175+#, python-format
176+msgid "No Invoice Lines !"
177+msgstr "Mancano voci nella fattura !"
178+
179+#. module: account_invoice_entry_date
180+#: field:account.invoice,registration_date:0
181+msgid "Registration Date"
182+msgstr "Data di registrazione"
183+
184+#. module: account_invoice_entry_date
185+#: code:addons/account_invoice_entry_date/invoice.py:57
186+#, python-format
187+msgid "Error date !"
188+msgstr "Data errata !"
189+
190
191=== added file 'account_invoice_entry_date/invoice.py'
192--- account_invoice_entry_date/invoice.py 1970-01-01 00:00:00 +0000
193+++ account_invoice_entry_date/invoice.py 2011-09-10 17:22:22 +0000
194@@ -0,0 +1,77 @@
195+# -*- coding: utf-8 -*-
196+##############################################################################
197+#
198+# OpenERP, Open Source Management Solution
199+# Copyright (C) 2004-2010 ISA srl (<http://www.isa.it>).
200+#
201+# This program is free software: you can redistribute it and/or modify
202+# it under the terms of the GNU Affero General Public License as
203+# published by the Free Software Foundation, either version 3 of the
204+# License, or (at your option) any later version.
205+#
206+# This program is distributed in the hope that it will be useful,
207+# but WITHOUT ANY WARRANTY; without even the implied warranty of
208+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
209+# GNU Affero General Public License for more details.
210+#
211+# You should have received a copy of the GNU Affero General Public License
212+# along with this program. If not, see <http://www.gnu.org/licenses/>.
213+#
214+##############################################################################
215+
216+import time
217+from osv import fields, osv, orm
218+from tools.translate import _
219+from datetime import datetime
220+
221+class account_invoice(osv.osv):
222+
223+ _inherit = 'account.invoice'
224+ _columns = {
225+ 'registration_date':fields.date('Registration Date', states={'paid':[('readonly',True)], 'open':[('readonly',True)], 'close':[('readonly',True)]}, select=True, help="Keep empty to use the current date"),
226+ }
227+
228+ def action_move_create(self, cr, uid, ids, *args):
229+
230+ super(account_invoice,self).action_move_create(cr, uid, ids,*args)
231+
232+ for inv in self.browse(cr, uid, ids):
233+
234+ date_invoice=inv.date_invoice
235+
236+ reg_date = inv.registration_date
237+ if not inv.registration_date :
238+ if not inv.date_invoice:
239+ reg_date = time.strftime('%Y-%m-%d')
240+ else : reg_date = inv.date_invoice
241+
242+ if date_invoice and reg_date :
243+ if (date_invoice > reg_date) :
244+ raise osv.except_osv(_('Error date !'), _('The invoice date cannot be later than the date of registration!'))
245+
246+ #periodo
247+ date_start = inv.registration_date or inv.date_invoice or time.strftime('%Y-%m-%d')
248+ date_stop = inv.registration_date or inv.date_invoice or time.strftime('%Y-%m-%d')
249+
250+ period_ids = self.pool.get('account.period').search(cr, uid, [('date_start','<=',date_start),('date_stop','>=',date_stop), ('company_id', '=', inv.company_id.id)])
251+ if period_ids:
252+ period_id = period_ids[0]
253+
254+ self.write(cr, uid, [inv.id], {'registration_date':reg_date,'period_id':period_id,})
255+
256+ mov_date = reg_date or inv.date_invoice or time.strftime('%Y-%m-%d')
257+
258+ self.pool.get('account.move').write(cr, uid, [inv.move_id.id], {'state':'draft'})
259+
260+ sql="update account_move_line set period_id="+str(period_id)+",date='"+mov_date+"' where move_id = "+str(inv.move_id.id)
261+
262+ cr.execute(sql)
263+
264+ self.pool.get('account.move').write(cr, uid, [inv.move_id.id], {'period_id':period_id,'date':mov_date})
265+
266+ self.pool.get('account.move').write(cr, uid, [inv.move_id.id], {'state':'posted'})
267+
268+ self._log_event(cr, uid, ids)
269+ return True
270+
271+account_invoice()
272
273=== added file 'account_invoice_entry_date/invoice_view.xml'
274--- account_invoice_entry_date/invoice_view.xml 1970-01-01 00:00:00 +0000
275+++ account_invoice_entry_date/invoice_view.xml 2011-09-10 17:22:22 +0000
276@@ -0,0 +1,39 @@
277+<?xml version="1.0" encoding="utf-8"?>
278+<openerp>
279+ <data>
280+ <record id="invoice_form_reg_date" model="ir.ui.view">
281+ <field name="name">account.invoice.form.reg_date</field>
282+ <field name="model">account.invoice</field>
283+ <field name="inherit_id" ref="account.invoice_form"/>
284+ <field name="arch" type="xml">
285+ <field name="date_invoice" position="after">
286+ <field name="registration_date"></field>
287+ </field>
288+ </field>
289+ </record>
290+
291+ <record id="invoice_tree_reg_date" model="ir.ui.view">
292+ <field name="name">account.invoice.tree.reg_date</field>
293+ <field name="model">account.invoice</field>
294+ <field name="inherit_id" ref="account.invoice_tree"/>
295+ <field name="arch" type="xml">
296+ <field name="date_invoice" position="after">
297+ <field name="registration_date"></field>
298+ </field>
299+ </field>
300+ </record>
301+
302+ <record id="invoice_supplier_form_reg_date" model="ir.ui.view">
303+ <field name="name">account.invoice.supplier.form.reg_date</field>
304+ <field name="model">account.invoice</field>
305+ <field name="inherit_id" ref="account.invoice_supplier_form"/>
306+ <field name="arch" type="xml">
307+ <field name="date_invoice" position="after">
308+ <field name="registration_date"></field>
309+ </field>
310+ </field>
311+ </record>
312+
313+
314+ </data>
315+</openerp>