Merge lp:~elbati/openobject-italia/7-l10n_it_vat_registries_simplified into lp:~openobject-italia-core-devs/openobject-italia/italian-addons-7.0

Proposed by Lorenzo Battistini
Status: Merged
Merged at revision: 214
Proposed branch: lp:~elbati/openobject-italia/7-l10n_it_vat_registries_simplified
Merge into: lp:~openobject-italia-core-devs/openobject-italia/italian-addons-7.0
Diff against target: 1529 lines (+494/-625)
13 files modified
l10n_it_vat_registries/AUTHORS.txt (+1/-1)
l10n_it_vat_registries/__init__.py (+3/-3)
l10n_it_vat_registries/__openerp__.py (+3/-3)
l10n_it_vat_registries/account.py (+0/-48)
l10n_it_vat_registries/account_view.xml (+0/-17)
l10n_it_vat_registries/invoice.py (+104/-309)
l10n_it_vat_registries/reports.xml (+18/-9)
l10n_it_vat_registries/templates/registro_iva_acquisti.mako (+114/-73)
l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako (+93/-46)
l10n_it_vat_registries/templates/registro_iva_vendite.mako (+94/-51)
l10n_it_vat_registries/wizard/__init__.py (+2/-2)
l10n_it_vat_registries/wizard/print_registro_iva.py (+45/-53)
l10n_it_vat_registries/wizard/print_registro_iva.xml (+17/-10)
To merge this branch: bzr merge lp:~elbati/openobject-italia/7-l10n_it_vat_registries_simplified
Reviewer Review Type Date Requested Status
OpenERP Italia core devs Pending
Review via email: mp+162188@code.launchpad.net
To post a comment you must log in.
218. By Lorenzo Battistini

[imp] tax codes

219. By Lorenzo Battistini

[imp] totals and layout

220. By Lorenzo Battistini

[imp] wizard

221. By Lorenzo Battistini

[IMP] allow using multiple periods

222. By Lorenzo Battistini

[add] tax amount sign

223. By Lorenzo Battistini

[add] distinguo gli imponibili

224. By Lorenzo Battistini

[add] missing files

225. By Lorenzo Battistini

[fix] riepilogo imponibili

226. By Lorenzo Battistini

[imp] font size

Revision history for this message
Sergio Corato (icsergio) wrote :

Ottimo lavoro!

Puoi mettere anche l'opzione di impostare manualmente il numero di pagina di partenza? Serve in quanto la numerazione dev'essere progressiva e unica per tutto l'anno.

Revision history for this message
Sergio Corato (icsergio) wrote :

ah, dimenticavo:
- codice attività e registro imprese direi che in questo caso non servono
- nel wizard di scelta dei sezionali limitare la scelta a domain="[('type', 'in', ('sale','purchase','sale_refund','purchase_refund'))]
- l'indicazione del periodo temporale lo farei in mesi (anche perchè effettivamente si basa sui periodi e non sulle date) sia nell'ottica di evitare di calcoli possibilmente errati, sia perchè è usuale indicare i periodi

Revision history for this message
Sergio Corato (icsergio) wrote :

stasera vado a colpi :)

Non si potrebbe impostare l'inversione del segno degli importi per il registro acquisti (e resi su acquisti) evitando scelte "difficili" per un utente base?

Non credo sia possibile avere casi in cui si scelga di stampare in maniera diversa gli importi, neanche di stampare fatture acquisti e vendite insieme (smentitemi se sbaglio), caso in cui sarebbe pensabile dire "non confondo i valori dell'iva a credito e a debito"

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

On 05/05/2013 11:03 PM, Sergio Corato wrote:

> Puoi mettere anche l'opzione di impostare manualmente il numero di pagina di partenza? Serve in quanto la numerazione dev'essere progressiva e unica per tutto l'anno.

Nel momento in cui stampi tutto l'anno, avrai la numerazione corretta a
partire dall'inizio dell'anno.

227. By Lorenzo Battistini

[del] codice attività, registro imprese

228. By Lorenzo Battistini

[imp] journal domain

229. By Lorenzo Battistini

[add] on_type_changed

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

On 05/05/2013 11:26 PM, Sergio Corato wrote:
> - codice attività e registro imprese direi che in questo caso non servono

fatto

> - nel wizard di scelta dei sezionali limitare la scelta a domain="[('type', 'in', ('sale','purchase','sale_refund','purchase_refund'))]

fatto

> - l'indicazione del periodo temporale lo farei in mesi (anche perchè effettivamente si basa sui periodi e non sulle date) sia nell'ottica di evitare di calcoli possibilmente errati, sia perchè è usuale indicare i periodi

Cioè stamperesti il nome del periodo? "Dal 01/2013 al 12/2013" ?

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

On 05/05/2013 11:45 PM, Sergio Corato wrote:
> Non si potrebbe impostare l'inversione del segno degli importi per il registro acquisti (e resi su acquisti) evitando scelte "difficili" per un utente base?

Ho aggiunto l'onchange sul campo type

Revision history for this message
Sergio Corato (icsergio) wrote :

ehmm, la liquidazione IVA si stampa mese per mese

poi basta che riprendi quello che avevo già messo nel mio branch, l'avevo
già fatto

2013/5/6 Lorenzo Battistini - Agile BG <email address hidden>

> On 05/05/2013 11:03 PM, Sergio Corato wrote:
>
> > Puoi mettere anche l'opzione di impostare manualmente il numero di
> pagina di partenza? Serve in quanto la numerazione dev'essere progressiva e
> unica per tutto l'anno.
>
> Nel momento in cui stampi tutto l'anno, avrai la numerazione corretta a
> partire dall'inizio dell'anno.
>
> --
>
> https://code.launchpad.net/~elbati/openobject-italia/7-l10n_it_vat_registries_simplified/+merge/162188
> Your team OpenERP Italia core devs is requested to review the proposed
> merge of lp:~elbati/openobject-italia/7-l10n_it_vat_registries_simplified
> into lp:openobject-italia/7.0.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openobject-italia-core-devs
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~openobject-italia-core-devs
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Sergio Corato (icsergio) wrote :

stamperei "Marzo 2013" oppure "Marzo 2013 - Aprile 2013"

2013/5/6 Lorenzo Battistini - Agile BG <email address hidden>

> On 05/05/2013 11:26 PM, Sergio Corato wrote:
> > - codice attività e registro imprese direi che in questo caso non servono
>
> fatto
>
> > - nel wizard di scelta dei sezionali limitare la scelta a
> domain="[('type', 'in',
> ('sale','purchase','sale_refund','purchase_refund'))]
>
> fatto
>
> > - l'indicazione del periodo temporale lo farei in mesi (anche perchè
> effettivamente si basa sui periodi e non sulle date) sia nell'ottica di
> evitare di calcoli possibilmente errati, sia perchè è usuale indicare i
> periodi
>
> Cioè stamperesti il nome del periodo? "Dal 01/2013 al 12/2013" ?
>
> --
>
> https://code.launchpad.net/~elbati/openobject-italia/7-l10n_it_vat_registries_simplified/+merge/162188
> Your team OpenERP Italia core devs is requested to review the proposed
> merge of lp:~elbati/openobject-italia/7-l10n_it_vat_registries_simplified
> into lp:openobject-italia/7.0.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openobject-italia-core-devs
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~openobject-italia-core-devs
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Sergio Corato (icsergio) wrote :

Ho visto che la progressione è per data invece che per numero di registrazione (protocollo) della fattura, bisognerebbe correggerla

Per quanto riguarda la progressività, è necessario invece che sia corretta a priori, con una correzione al modulo account_invoice_entry_date come proposta (in verifica) su https://code.launchpad.net/~a-camilli/openobject-italia/6.1-fix-controllo-data-registrazione-consecutiva

Manca infine il numero fattura dato dal fornitore

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

On 05/06/2013 01:56 PM, Sergio Corato wrote:
> ehmm, la liquidazione IVA si stampa mese per mese

Ok però a quanto ne so i registri IVA vanno stampati in definitivo
quando si fa la dichiarazione IVA, quindi una volta l'anno.
Comunque, per dare maggiore libertà, possiamo aggiungere la possibilità
di scegliere la pagina di partenza.

Revision history for this message
Sergio Corato (icsergio) wrote :

Il 07/05/2013 09:25, Lorenzo Battistini - Agile BG ha scritto:
> On 05/06/2013 01:56 PM, Sergio Corato wrote:
>> ehmm, la liquidazione IVA si stampa mese per mese
>
> Ok però a quanto ne so i registri IVA vanno stampati in definitivo
> quando si fa la dichiarazione IVA, quindi una volta l'anno.
> Comunque, per dare maggiore libertà, possiamo aggiungere la possibilità
> di scegliere la pagina di partenza.
>
ok

per chi fa la liquidazione trimestrale, avendo i periodi trimestrali
dovrebbe essere già a posto (resta solo fuori il calcolo dell'interesse,
ma è un dettaglio)

invece bisognerebbe aggiungere la funzionalità del registro "Annotazioni
CEE" con:
- il mako (uguale alle vendite)
- il sezionale (tipo sale_CEE)
- la duplicazione della registrazione del movimento della fattura di
acquisto CEE sul sezionale di cui sopra
- dovrebbe anche essere necessario mettere una casella nella fattura di
acquisto per evidenziare che è intraCEE
(non mi sembra ci sia già qualcosa a riguardo, o mi sono perso?)

--
Sergio Corato

IcsTools.it

web : www.icstools.it
skype : sergiocorato
mail : <email address hidden>

230. By Lorenzo Battistini

[add] possibilità
di scegliere la pagina di partenza

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

On 05/07/2013 02:12 PM, Sergio Corato wrote:
> Il 07/05/2013 09:25, Lorenzo Battistini - Agile BG ha scritto:
>> Comunque, per dare maggiore libertà, possiamo aggiungere la possibilità
>> di scegliere la pagina di partenza.

Fatto.

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

On 05/07/2013 02:16 PM, Sergio Corato wrote:
> invece bisognerebbe aggiungere la funzionalità del registro
> "Annotazioni CEE" con: - il mako (uguale alle vendite) - il sezionale
> (tipo sale_CEE) - la duplicazione della registrazione del movimento
> della fattura di acquisto CEE sul sezionale di cui sopra - dovrebbe
> anche essere necessario mettere una casella nella fattura di acquisto
> per evidenziare che è intraCEE (non mi sembra ci sia già qualcosa a
> riguardo, o mi sono perso?)

Per le nuove funzionalità farei delle MP a parte, altrimenti rischiamo
di perderci.
In questa punterei principalmente al refactoring dei registri esistenti.

231. By Lorenzo Battistini

[add] supplier_invoice_number

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

On 05/07/2013 01:04 AM, Sergio Corato wrote:
> Manca infine il numero fattura dato dal fornitore

Aggiunto.

Revision history for this message
Sergio Corato (icsergio) wrote :

Direi che adesso è funzionale e usabile, per me va bene. Per il back-port sulla 6.1, basta aggiungere il campo mancante vedo, mi sembra sia l'unica differenza tra le due.

Per promemoria indico quello che è rimasto fuori:
- IVA esigibile / non esigibile
- IVA e registro annotazioni CEE

Revision history for this message
Davide Corio (enlightx-deactivatedaccount) wrote :

Questo MP è da considerare obsoleto?

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

Lo stato è 'merged' quindi le modifiche sono già finite nel target branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_it_vat_registries/AUTHORS.txt'
2--- l10n_it_vat_registries/AUTHORS.txt 2013-01-08 23:01:16 +0000
3+++ l10n_it_vat_registries/AUTHORS.txt 2013-05-09 15:50:30 +0000
4@@ -1,2 +1,2 @@
5-Lorenzo Battistini <lorenzo.battistini@domsense.com>
6+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
7 Ingrid Barcaro
8
9=== modified file 'l10n_it_vat_registries/__init__.py'
10--- l10n_it_vat_registries/__init__.py 2013-01-29 22:08:50 +0000
11+++ l10n_it_vat_registries/__init__.py 2013-05-09 15:50:30 +0000
12@@ -1,7 +1,7 @@
13 # -*- coding: utf-8 -*-
14 ##############################################################################
15 #
16-# Copyright (C) 2011 Associazione OpenERP Italia
17+# Copyright (C) 2011-2013 Associazione OpenERP Italia
18 # (<http://www.openerp-italia.org>).
19 #
20 # This program is free software: you can redistribute it and/or modify
21@@ -12,7 +12,7 @@
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25-# GNU General Public License for more details.
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@@ -20,5 +20,5 @@
31 ##############################################################################
32
33 import wizard
34+import invoice
35 import account
36-import invoice
37
38=== modified file 'l10n_it_vat_registries/__openerp__.py'
39--- l10n_it_vat_registries/__openerp__.py 2013-02-18 19:37:15 +0000
40+++ l10n_it_vat_registries/__openerp__.py 2013-05-09 15:50:30 +0000
41@@ -1,7 +1,7 @@
42 # -*- coding: utf-8 -*-
43 ##############################################################################
44 #
45-# Copyright (C) 2011-2012 Associazione OpenERP Italia
46+# Copyright (C) 2011-2013 Associazione OpenERP Italia
47 # (<http://www.openerp-italia.org>).
48 # Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
49 # Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
50@@ -14,7 +14,7 @@
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 General Public License for more details.
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@@ -33,8 +33,8 @@
60 ],
61 "update_xml" : [
62 'reports.xml',
63+ 'wizard/print_registro_iva.xml',
64 'account_view.xml',
65- 'wizard/print_registro_iva.xml',
66 ],
67 "demo_xml" : [],
68 "active": False,
69
70=== added file 'l10n_it_vat_registries/account.py'
71--- l10n_it_vat_registries/account.py 1970-01-01 00:00:00 +0000
72+++ l10n_it_vat_registries/account.py 2013-05-09 15:50:30 +0000
73@@ -0,0 +1,30 @@
74+# -*- coding: utf-8 -*-
75+##############################################################################
76+#
77+# Copyright (C) 2013 Associazione OpenERP Italia
78+# (<http://www.openerp-italia.org>).
79+#
80+# This program is free software: you can redistribute it and/or modify
81+# it under the terms of the GNU Affero General Public License as published
82+# by the Free Software Foundation, either version 3 of the License, or
83+# (at your option) any later version.
84+#
85+# This program is distributed in the hope that it will be useful,
86+# but WITHOUT ANY WARRANTY; without even the implied warranty of
87+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88+# GNU Affero General Public License for more details.
89+#
90+# You should have received a copy of the GNU Affero General Public License
91+# along with this program. If not, see <http://www.gnu.org/licenses/>.
92+#
93+##############################################################################
94+
95+from openerp.osv import fields, osv
96+from openerp.tools.translate import _
97+
98+class account_tax_code(osv.osv):
99+ _inherit = "account.tax.code"
100+
101+ _columns = {
102+ 'is_base': fields.boolean('Is base', help="This tax code is used for base amounts (field used by VAT registries)"),
103+ }
104
105=== removed file 'l10n_it_vat_registries/account.py'
106--- l10n_it_vat_registries/account.py 2013-01-29 22:08:50 +0000
107+++ l10n_it_vat_registries/account.py 1970-01-01 00:00:00 +0000
108@@ -1,48 +0,0 @@
109-# -*- coding: utf-8 -*-
110-##############################################################################
111-#
112-# Copyright (C) 2011-2012 Associazione OpenERP Italia
113-# (<http://www.openerp-italia.org>).
114-# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
115-# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
116-#
117-# This program is free software: you can redistribute it and/or modify
118-# it under the terms of the GNU Affero General Public License as published
119-# by the Free Software Foundation, either version 3 of the License, or
120-# (at your option) any later version.
121-#
122-# This program is distributed in the hope that it will be useful,
123-# but WITHOUT ANY WARRANTY; without even the implied warranty of
124-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
125-# GNU Affero General Public License for more details.
126-#
127-# You should have received a copy of the GNU Affero General Public License
128-# along with this program. If not, see <http://www.gnu.org/licenses/>.
129-#
130-##############################################################################
131-
132-from osv import fields, osv
133-from tools.translate import _
134-
135-
136-class account_tax(osv.osv):
137-
138- _inherit = 'account.tax'
139- _columns = {
140- 'exclude_from_registries': fields.boolean(
141- 'Exclude from VAT registries'),
142- 'base_tax_ids': fields.one2many(
143- 'account.tax', 'base_code_id', 'Base Taxes'), # serve ancora?
144- }
145- _sql_constraints = [
146- ('name_uniq', 'UNIQUE(name)', 'The tax name must be unique!'),
147- ]
148-
149- def get_account_tax(self, inv_tax):
150- if inv_tax.tax_code_id:
151- return self.get_account_tax_by_tax_code(inv_tax.tax_code_id)
152- if inv_tax.base_code_id:
153- return self.get_account_tax_by_base_code(inv_tax.base_code_id)
154- raise osv.except_osv(_('Error'),
155- _('No tax codes for invoice tax %s') % str(inv_tax.name))
156-
157
158=== added file 'l10n_it_vat_registries/account_view.xml'
159--- l10n_it_vat_registries/account_view.xml 1970-01-01 00:00:00 +0000
160+++ l10n_it_vat_registries/account_view.xml 2013-05-09 15:50:30 +0000
161@@ -0,0 +1,16 @@
162+<?xml version="1.0"?>
163+<openerp>
164+ <data>
165+ <record id="view_tax_code_form" model="ir.ui.view">
166+ <field name="name">account.tax.code.form</field>
167+ <field name="model">account.tax.code</field>
168+ <field name="inherit_id" ref="account.view_tax_code_form"></field>
169+ <field name="arch" type="xml">
170+ <field name="sign" position="after">
171+ <field name="is_base"/>
172+ </field>
173+ </field>
174+ </record>
175+ </data>
176+</openerp>
177+
178
179=== removed file 'l10n_it_vat_registries/account_view.xml'
180--- l10n_it_vat_registries/account_view.xml 2013-01-08 23:01:16 +0000
181+++ l10n_it_vat_registries/account_view.xml 1970-01-01 00:00:00 +0000
182@@ -1,17 +0,0 @@
183-<?xml version="1.0" encoding="utf-8"?>
184-<openerp>
185- <data>
186-
187- <record id="view_tax_form" model="ir.ui.view">
188- <field name="name">account.tax.form</field>
189- <field name="model">account.tax</field>
190- <field name="type">form</field>
191- <field name="inherit_id" ref="account.view_tax_form"></field>
192- <field name="arch" type="xml">
193- <field name="active" position="after">
194- <field name="exclude_from_registries"/>
195- </field>
196- </field>
197- </record>
198- </data>
199-</openerp>
200
201=== modified file 'l10n_it_vat_registries/invoice.py'
202--- l10n_it_vat_registries/invoice.py 2013-04-24 10:14:49 +0000
203+++ l10n_it_vat_registries/invoice.py 2013-05-09 15:50:30 +0000
204@@ -1,8 +1,8 @@
205 # -*- coding: utf-8 -*-
206 ##############################################################################
207-#
208-# Copyright (C) 2011 Associazione OpenERP Italia
209-# (<http://www.openerp-italia.org>).
210+#
211+# Copyright (C) 2011-2013 Associazione OpenERP Italia
212+# (<http://www.openerp-italia.org>).
213 #
214 # This program is free software: you can redistribute it and/or modify
215 # it under the terms of the GNU Affero General Public License as published
216@@ -22,328 +22,123 @@
217 import time
218 from report import report_sxw
219 from tools.translate import _
220-from decimal import *
221-import netsvc
222+import logging
223+from datetime import datetime
224+
225+_logger = logging.getLogger(__name__)
226
227 class Parser(report_sxw.rml_parse):
228-
229- logger = netsvc.Logger()
230-
231- def _get_partner_type(self, move_line):
232- partner_type = ''
233- for line in move_line.move_id.line_id:
234- if line.account_id.type == 'payable' or line.account_id.type == 'receivable':
235- if not partner_type:
236- partner_type = line.account_id.type
237- elif partner_type != line.account_id.type:
238- raise Exception(
239- _('The move %s has different partner account type') % move_line.move_id.name)
240- return partner_type
241-
242- def _move_total(self, move_line):
243- partner_type = self._get_partner_type(move_line)
244- total = 0.0
245- for line in move_line.move_id.line_id:
246- if line.account_id.type == partner_type:
247- total += (line.debit or line.credit)
248- return total
249-
250- # Metto al tax code il segno dell'importo dell'imposta.
251- # Il tax code ha l'importo in valuta base, ma ha segno negativo per l'IVA a credito (da stampare positiva)
252- # e per le note di credito (da stampare negative)
253- def _get_amount_with_sign(self, tax_code_amount, amount):
254- return abs(tax_code_amount) * cmp(amount, 0)
255-
256- def _is_refund(self, move_line):
257- if self._get_partner_type(move_line) == 'receivable' and move_line.debit > move_line.credit:
258- return True
259- if self._get_partner_type(move_line) == 'payable' and move_line.debit < move_line.credit:
260- return True
261-
262- def _get_line_amount_with_sign(self, move_line):
263- if self._get_partner_type(move_line) == 'receivable':
264- return self._get_amount_with_sign(move_line.tax_amount, move_line.credit - move_line.debit)
265- if self._get_partner_type(move_line) == 'payable':
266- return self._get_amount_with_sign(move_line.tax_amount, move_line.debit - move_line.credit)
267-
268- # in valuta base
269- def _get_invoice_amount_total(self, invoice):
270- total = 0.0
271- for inv_tax in invoice.tax_line:
272- total += self._get_amount_with_sign(inv_tax.base_amount, inv_tax.base) \
273- + self._get_amount_with_sign(inv_tax.tax_amount, inv_tax.amount)
274- return total
275-
276- # in valuta base
277- def _get_invoice_amount_untaxed(self, invoice):
278- total = 0.0
279- for inv_tax in invoice.tax_line:
280- total += self._get_amount_with_sign(inv_tax.base_amount, inv_tax.base)
281- return total
282+
283+ def _tax_amounts_by_code(self, move):
284+ res={}
285+ for move_line in move.line_id:
286+ if move_line.tax_code_id and move_line.tax_amount:
287+ if not res.get(move_line.tax_code_id.id):
288+ res[move_line.tax_code_id.id] = 0.0
289+ self.localcontext['used_tax_codes'][move_line.tax_code_id.id] = True
290+ res[move_line.tax_code_id.id] += (move_line.tax_amount
291+ * self.localcontext['data']['tax_sign'])
292+ return res
293
294 def _get_tax_lines(self, move):
295 res=[]
296- tax_obj = self.pool.get('account.tax')
297- cur_pool = self.pool.get('res.currency')
298- inv_pool = self.pool.get('account.invoice')
299+ tax_code_obj=self.pool.get('account.tax.code')
300 # index è usato per non ripetere la stampa dei dati fattura quando ci sono più codici IVA
301 index=0
302- totale_iva = 0.0
303- totale_iva_inded = 0.0
304- invoice_amount_total = 0.0
305- invoice_amount_untaxed = 0.0
306- related_invoices = []
307-
308- ''' riusciamo a essere sempre indipendenti dalle fatture?
309- # se c'è l'oggetto fattura, utilizzo il calcolo su fattura
310- for move_line in move.line_id:
311- if move_line.invoice and move_line.invoice.id not in related_invoices:
312- related_invoices.append(move_line.invoice.id)
313- '''
314-
315- if related_invoices:
316- for invoice_id in related_invoices:
317- return self._get_tax_lines_by_invoice(inv_pool.browse(self.cr, self.uid, invoice_id))
318-
319- for move_line in move.line_id:
320- tax_item = {}
321- if move_line.tax_code_id and move_line.tax_code_id.tax_ids:
322- # Nel wizard ho già controllato che le eventuali diverse
323- # imposte abbiamo la stessa aliquota.
324- # Le diverse imposte devono comunque usare gli stessi tax code
325- main_tax = tax_obj.get_main_tax(move_line.tax_code_id.tax_ids[0])
326- if main_tax.exclude_from_registries:
327- self.logger.notifyChannel("l10n_it_vat_registries", netsvc.LOG_INFO,
328- _('The tax %s is excluded from registries') % main_tax.name)
329- continue
330- # sommo gli imponibili relativi all'imposta corrente
331- base_amount = 0.0
332- for line in move_line.move_id.line_id:
333- if line.tax_code_id.id == main_tax.base_code_id.id:
334- base_amount += self._get_line_amount_with_sign(line)
335- if base_amount and main_tax.amount:
336- actual_tax_amount = base_amount * main_tax.amount
337- else:
338- actual_tax_amount = move_line.tax_amount
339- actual_tax_amount = cur_pool.round(
340- self.cr, self.uid, move.company_id.currency_id,
341- actual_tax_amount)
342- # calcolo % indetraibile
343- non_deductible = 0.0
344- if abs(actual_tax_amount) != abs(move_line.tax_amount):
345- non_deductible = 100
346- if move_line.tax_amount:
347- non_deductible = 100 - abs((
348- move_line.tax_amount * 100.0) / actual_tax_amount)
349- non_deductible = cur_pool.round(
350- self.cr, self.uid, move.company_id.currency_id,
351- non_deductible)
352- # calcolo il totale dell'operazione
353- invoice_amount_total = self._move_total(move_line)
354- if self._is_refund(move_line):
355- invoice_amount_total = - invoice_amount_total
356- str_non_deductible = str(non_deductible).split('.')[0]
357- tax_item = {
358- 'tax_percentage': main_tax.amount and str(
359- main_tax.amount * 100).split('.')[0] or
360- move_line.tax_code_id.name,
361- 'tax_code_name': move_line.tax_code_id.name,
362- 'base': base_amount,
363- 'amount': actual_tax_amount,
364- 'non_deductible': str_non_deductible != '0' and
365- str_non_deductible or '',
366- 'index': index,
367- 'amount_total': invoice_amount_total,
368- }
369- res.append(tax_item)
370- iva = cur_pool.round(
371- self.cr, self.uid, move.company_id.currency_id,
372- (actual_tax_amount * (100 - non_deductible) * 0.01))
373- iva_inded = cur_pool.round(
374- self.cr, self.uid, move.company_id.currency_id,
375- (actual_tax_amount * non_deductible * 0.01))
376- tax_difference= (iva + iva_inded) - actual_tax_amount
377- # se risulta un'eccedenza, la tolgo dalla parte detraibile
378- if tax_difference > 0:
379- iva = iva - tax_difference
380- # se risulta una mancanza, la aggiungo alla parte indetraibile
381- elif tax_difference < 0:
382- iva_inded = iva_inded + tax_difference
383- totale_iva += iva
384- invoice_amount_untaxed += base_amount
385- totale_iva_inded += iva_inded
386- index += 1
387-
388- if tax_item:
389- if tax_item['tax_code_name'] not in self.localcontext[
390- 'tax_codes']:
391- self.localcontext['tax_codes'][tax_item[
392- 'tax_code_name']] = {
393- 'base': tax_item['base'],
394- 'amount': tax_item['amount'],
395- }
396- else:
397- self.localcontext['tax_codes'][tax_item[
398- 'tax_code_name']]['base'] += tax_item['base']
399- self.localcontext['tax_codes'][tax_item[
400- 'tax_code_name']]['amount'] += tax_item['amount']
401-
402- self.localcontext['totali'][
403- 'totale_operazioni'] += invoice_amount_total
404- self.localcontext['totali'][
405- 'totale_imponibili'] += invoice_amount_untaxed
406- self.localcontext['totali']['totale_iva'] += totale_iva
407- self.localcontext['totali']['totale_iva_inded'] += totale_iva_inded
408-
409- return res
410-
411- def _get_tax_lines_by_invoice(self, invoice):
412+ invoice = False
413+ for move_line in move.line_id:
414+ if move_line.invoice:
415+ if invoice and invoice.id != move_line.invoice.id:
416+ raise Exception(_("Move %s contains different invoices") % move.name)
417+ invoice = move_line.invoice
418+ amounts_by_code = self._tax_amounts_by_code(move)
419+ for tax_code_id in amounts_by_code:
420+ tax_code = tax_code_obj.browse(self.cr, self.uid, tax_code_id)
421+ tax_item = {
422+ 'tax_code_name': tax_code.name,
423+ 'amount': amounts_by_code[tax_code_id],
424+ 'index': index,
425+ 'invoice_date': (invoice and invoice.date_invoice
426+ or move.date or ''),
427+ 'supplier_invoice_number': (invoice and invoice.supplier_invoice_number or '')
428+ }
429+ res.append(tax_item)
430+ index += 1
431+ return res
432+
433+ def build_parent_tax_codes(self, tax_code):
434+ res={}
435+ if tax_code.parent_id and tax_code.parent_id.parent_id:
436+ res[tax_code.parent_id.id]=True
437+ res.update(self.build_parent_tax_codes(tax_code.parent_id))
438+ return res
439+
440+ def _compute_totals(self, tax_code_ids):
441 res=[]
442- tax_obj = self.pool.get('account.tax')
443- # index è usato per non ripetere la stampa dei dati fattura quando ci sono più codici IVA
444- index = 0
445- totale_iva = 0.0
446- totale_iva_inded = 0.0
447- invoice_amount_total = 0.0
448- invoice_amount_untaxed = 0.0
449- for inv_tax in invoice.tax_line:
450- tax_item = {}
451- if inv_tax.base_code_id and inv_tax.tax_code_id:
452- account_tax = tax_obj.get_account_tax(inv_tax)
453- if account_tax.exclude_from_registries:
454- self.logger.notifyChannel("l10n_it_vat_registries",
455- netsvc.LOG_INFO, _(
456- 'The tax %s is excluded from registries')
457- % account_tax.name)
458- continue
459- account_tax_amount = account_tax.amount
460- invoice_amount_total = self._get_invoice_amount_total(invoice)
461- invoice_amount_untaxed = self._get_invoice_amount_untaxed(
462- invoice)
463- amount = self._get_amount_with_sign(inv_tax.tax_amount,
464- inv_tax.amount)
465- base = self._get_amount_with_sign(inv_tax.base_amount,
466- inv_tax.base)
467- # calcolo le note di credito con segno invertito
468- if invoice.type in ('in_refund', 'out_refund'):
469- amount = -amount
470- base = -base
471- invoice_amount_untaxed = -invoice_amount_untaxed
472- invoice_amount_total = -invoice_amount_total
473- tax_item = {
474- 'tax_percentage': account_tax_amount and str(
475- account_tax_amount * 100).split('.')[0] or
476- inv_tax.tax_code_id.name,
477- 'base': base,
478- 'amount': amount, # in valuta base
479- 'non_deductible': 0.0,
480- 'index': index,
481- 'amount_total': invoice_amount_total,
482- }
483- res.append(tax_item)
484- totale_iva += amount
485- index += 1
486- # Se non c'è il tax code imponibile, cerco la tassa relativa alla parte non deducibile
487- elif inv_tax.tax_code_id:
488- tax = tax_obj.get_main_tax(tax_obj.get_account_tax(inv_tax))
489- if tax.exclude_from_registries:
490- self.logger.notifyChannel("l10n_it_vat_registries",
491- netsvc.LOG_INFO,
492- _('The tax %s is excluded from registries') % tax.name)
493- continue
494- for inv_tax_2 in invoice.tax_line:
495- if inv_tax_2.base_code_id and not inv_tax_2.tax_code_id:
496- base_tax = tax_obj.get_main_tax(
497- tax_obj.get_account_tax(inv_tax_2))
498- # Se hanno la stessa tassa
499- if base_tax.id == tax.id:
500- # Uso il valore assoluto perchè riferendosi
501- # alla stessa imposta non ci possono essere
502- # segni differenti
503- non_deductible = (abs(inv_tax_2.base_amount) /
504- (abs(inv_tax.base_amount) + abs(
505- inv_tax_2.base_amount)) * 100)
506- invoice_amount_total = \
507- self._get_invoice_amount_total(invoice)
508- invoice_amount_untaxed = \
509- self._get_invoice_amount_untaxed(invoice)
510- amount = self._get_amount_with_sign(
511- inv_tax.tax_amount, inv_tax.amount)
512- base = self._get_amount_with_sign(
513- inv_tax.base_amount, inv_tax.base)
514- amount2 = self._get_amount_with_sign(
515- inv_tax_2.tax_amount, inv_tax_2.amount)
516- base2 = self._get_amount_with_sign(
517- inv_tax_2.base_amount, inv_tax_2.base)
518- # calcolo le note di credito con segno invertito
519- if invoice.type in ('in_refund', 'out_refund'):
520- amount = -amount
521- base = -base
522- amount2 = -amount2
523- base2 = -base2
524- invoice_amount_untaxed = \
525- -invoice_amount_untaxed
526- invoice_amount_total = -invoice_amount_total
527- tax_item = {
528- 'tax_percentage': base_tax.amount and str(
529- base_tax.amount * 100).split('.')[0] or
530- inv_tax.tax_code_id.name,
531- 'base': base + base2,
532- 'amount': amount + amount2,
533- 'non_deductible': non_deductible and str(
534- non_deductible).split('.')[0] or '',
535- 'index': index,
536- 'amount_total': invoice_amount_total,
537- }
538- res.append(tax_item)
539- totale_iva += amount
540- totale_iva_inded += amount2
541- index += 1
542- break
543- elif not inv_tax.tax_code_id and not inv_tax.base_code_id:
544- self.logger.notifyChannel("l10n_it_vat_registries",
545- netsvc.LOG_INFO,
546- _('The tax %s has no tax codes') % inv_tax.name)
547- continue
548- if tax_item:
549- if tax_item['tax_percentage'] not in self.localcontext[
550- 'tax_codes']:
551- self.localcontext['tax_codes'][tax_item[
552- 'tax_percentage']] = {
553- 'base': tax_item['base'],
554- 'amount': tax_item['amount'],
555- }
556- else:
557- self.localcontext['tax_codes'][tax_item[
558- 'tax_percentage']]['base'] += tax_item['base']
559- self.localcontext['tax_codes'][tax_item[
560- 'tax_percentage']]['amount'] += tax_item['amount']
561-
562- self.localcontext['totali'][
563- 'totale_operazioni'] += invoice_amount_total
564- self.localcontext['totali'][
565- 'totale_imponibili'] += invoice_amount_untaxed
566-# da analizzare self.totale_variazioni += invoice.amount_total
567- self.localcontext['totali']['totale_iva'] += totale_iva
568- self.localcontext['totali']['totale_iva_inded'] += totale_iva_inded
569-
570+ res_dict={}
571+ tax_code_obj = self.pool.get('account.tax.code')
572+ for period_id in self.localcontext['data']['period_ids']:
573+ for tax_code in tax_code_obj.browse(self.cr, self.uid,
574+ tax_code_ids, context={
575+ 'period_id': period_id,
576+ }):
577+ if not res_dict.get(tax_code.id):
578+ res_dict[tax_code.id] = 0.0
579+ res_dict[tax_code.id] += (tax_code.sum_period
580+ * self.localcontext['data']['tax_sign'])
581+ for tax_code_id in res_dict:
582+ tax_code = tax_code_obj.browse(self.cr, self.uid, tax_code_id)
583+ if res_dict[tax_code_id]:
584+ res.append((tax_code.name,res_dict[tax_code_id],tax_code.is_base))
585 return res
586+
587+ def _get_tax_codes(self):
588+ return self._compute_totals(self.localcontext['used_tax_codes'].keys())
589+
590+ def _get_tax_codes_totals(self):
591+ parent_codes = {}
592+ tax_code_obj = self.pool.get('account.tax.code')
593+ for tax_code in tax_code_obj.browse(self.cr, self.uid,
594+ self.localcontext['used_tax_codes'].keys()):
595+ parent_codes.update(self.build_parent_tax_codes(tax_code))
596+ return self._compute_totals(parent_codes.keys())
597+
598+ def _get_start_date(self):
599+ period_obj = self.pool.get('account.period')
600+ start_date = False
601+ for period in period_obj.browse(self.cr,self.uid,
602+ self.localcontext['data']['period_ids']):
603+ period_start = datetime.strptime(period.date_start, '%Y-%m-%d')
604+ if not start_date or start_date > period_start:
605+ start_date = period_start
606+ return start_date.strftime('%Y-%m-%d')
607+
608+ def _get_end_date(self):
609+ period_obj = self.pool.get('account.period')
610+ end_date = False
611+ for period in period_obj.browse(self.cr,self.uid,
612+ self.localcontext['data']['period_ids']):
613+ period_end = datetime.strptime(period.date_stop, '%Y-%m-%d')
614+ if not end_date or end_date < period_end:
615+ end_date = period_end
616+ return end_date.strftime('%Y-%m-%d')
617
618 def __init__(self, cr, uid, name, context):
619 super(Parser, self).__init__(cr, uid, name, context)
620 self.localcontext.update({
621- 'time': time,
622 'tax_lines': self._get_tax_lines,
623- 'totali': {
624- 'totale_operazioni': 0.0,
625- 'totale_imponibili': 0.0,
626- 'totale_variazioni': 0.0,
627- 'totale_iva': 0.0,
628- 'totale_iva_inded': 0.0,
629- },
630- 'tax_codes': {},
631+ 'tax_codes': self._get_tax_codes,
632+ 'tax_codes_totals': self._get_tax_codes_totals,
633+ 'used_tax_codes': {},
634+ 'start_date': self._get_start_date,
635+ 'end_date': self._get_end_date,
636 })
637
638+ def set_context(self, objects, data, ids, report_type=None):
639+ self.localcontext.update({
640+ 'fiscal_page_base': data.get('fiscal_page_base'),
641+ })
642+ return super(Parser, self).set_context(objects, data, ids, report_type=report_type)
643
644 report_sxw.report_sxw('report.registro_iva_vendite',
645 'registro_iva_vendite',
646
647=== modified file 'l10n_it_vat_registries/reports.xml'
648--- l10n_it_vat_registries/reports.xml 2013-01-08 23:01:16 +0000
649+++ l10n_it_vat_registries/reports.xml 2013-05-09 15:50:30 +0000
650@@ -37,8 +37,7 @@
651 <td>
652 <div>P. IVA: ${company.partner_id.vat or ''|entity}</div>
653 <div>Codice Fiscale: ${company.partner_id.fiscalcode or ''|entity}</div>
654- <div>Codice Attività:</div>
655- <div>Registro Imprese:</div>
656+
657 </td>
658 </tr>
659 </table>
660@@ -57,7 +56,11 @@
661 var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
662 for(var i in x) {
663 var y = document.getElementsByClassName(x[i]);
664- for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
665+ for(var j=0; j<y.length; ++j) {
666+ if(x[i] == 'page') {y[j].textContent = eval(vars[x[i]]) + ${fiscal_page_base};}
667+ else{y[j].textContent = vars[x[i]];}
668+ }
669+
670 }
671 }
672 </script>
673@@ -115,8 +118,7 @@
674 <td>
675 <div>P. IVA: ${company.partner_id.vat or ''|entity}</div>
676 <div>Codice Fiscale: ${company.partner_id.fiscalcode or ''|entity}</div>
677- <div>Codice Attività:</div>
678- <div>Registro Imprese:</div>
679+
680 </td>
681 </tr>
682 </table>
683@@ -135,7 +137,11 @@
684 var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
685 for(var i in x) {
686 var y = document.getElementsByClassName(x[i]);
687- for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
688+ for(var j=0; j<y.length; ++j) {
689+ if(x[i] == 'page') {y[j].textContent = eval(vars[x[i]]) + ${fiscal_page_base};}
690+ else{y[j].textContent = vars[x[i]];}
691+ }
692+
693 }
694 }
695 </script>
696@@ -193,8 +199,7 @@
697 <td>
698 <div>P. IVA: ${company.partner_id.vat or ''|entity}</div>
699 <div>Codice Fiscale: ${company.partner_id.fiscalcode or ''|entity}</div>
700- <div>Codice Attività:</div>
701- <div>Registro Imprese:</div>
702+
703 </td>
704 </tr>
705 </table>
706@@ -213,7 +218,11 @@
707 var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
708 for(var i in x) {
709 var y = document.getElementsByClassName(x[i]);
710- for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
711+ for(var j=0; j<y.length; ++j) {
712+ if(x[i] == 'page') {y[j].textContent = eval(vars[x[i]]) + ${fiscal_page_base};}
713+ else{y[j].textContent = vars[x[i]];}
714+ }
715+
716 }
717 }
718 </script>
719
720=== modified file 'l10n_it_vat_registries/templates/registro_iva_acquisti.mako'
721--- l10n_it_vat_registries/templates/registro_iva_acquisti.mako 2013-01-08 23:01:16 +0000
722+++ l10n_it_vat_registries/templates/registro_iva_acquisti.mako 2013-05-09 15:50:30 +0000
723@@ -19,20 +19,19 @@
724 <body>
725 <h2>Fatture Ricevute</h2>
726 <% setLang(objects[0].company_id.partner_id.lang or "en_US") %>
727- <table style="width:100%;" cellspacing="0">
728+ <table style="width:100%; font-size: small;" cellspacing="0">
729 <thead>
730 <tr>
731 <th class="left_without_line">Data registrazione</th>
732 <th class="left_without_line">Numero</th>
733 <th class="left_without_line">Ragione sociale</th>
734+ <th class="left_without_line">Numero registrazione</th>
735 <th class="left_without_line">Numero fattura</th>
736 <th class="left_without_line">Data fattura</th>
737- <th class="left_without_line">Causale</th>
738+ <th class="left_without_line">Sezionale</th>
739 <th class="right_without_line">Totale fattura</th>
740- <th class="right_without_line">Imponibile</th>
741- <th class="right_without_line">% IVA</th>
742 <th class="right_without_line">Imposta</th>
743- <th class="right_without_line">% inded.</th>
744+ <th class="right_without_line">Importo</th>
745 <th></th>
746 </tr>
747 </thead>
748@@ -63,7 +62,7 @@
749 </td><td class="left_without_line">
750 %endif
751 %if line['index']==0:
752- ${object.partner_id.name or ''| entity}
753+ ${object.partner_id.name or ''| entity}
754 %endif
755 %if line['index']==0:
756 </td><td class="left_with_line">
757@@ -79,19 +78,23 @@
758 </td><td class="left_without_line">
759 %endif
760 %if line['index']==0:
761- ${ formatLang(object.date,date=True) or '' | entity}
762- %endif
763- %if line['index']==0:
764- </td><td class="left_with_line">
765- %else:
766- </td><td class="left_without_line">
767- %endif
768- %if line['index']==0:
769- %if line['amount_total'] >= 0:
770- Fattura
771- %else:
772- Nota di credito
773- %endif
774+ ${ line['supplier_invoice_number'] or '' | entity}
775+ %endif
776+ %if line['index']==0:
777+ </td><td class="left_with_line">
778+ %else:
779+ </td><td class="left_without_line">
780+ %endif
781+ %if line['index']==0:
782+ ${ formatLang(line['invoice_date'],date=True) or '' | entity}
783+ %endif
784+ %if line['index']==0:
785+ </td><td class="left_with_line">
786+ %else:
787+ </td><td class="left_without_line">
788+ %endif
789+ %if line['index']==0:
790+ ${object.journal_id.name or ''| entity}
791 %endif
792 %if line['index']==0:
793 </td><td class="right_with_line">
794@@ -99,34 +102,19 @@
795 </td><td class="right_without_line">
796 %endif
797 %if line['index']==0:
798- ${ formatLang(line['amount_total']) | entity}
799- %endif
800- </td>
801- %if line['index']==0:
802- <td class="right_with_line">${ formatLang(line['base']) or ''| entity}</td>
803- %else:
804- <td class="right_without_line">${ formatLang(line['base']) or ''| entity}</td>
805- %endif
806- %if line['index']==0:
807- <td class="right_with_line">${ line['tax_percentage'] or ''| entity}</td>
808- %else:
809- <td class="right_without_line">${ line['tax_percentage'] or ''| entity}</td>
810- %endif
811- %if line['index']==0:
812- <td class="right_with_line">${ formatLang(line['amount']) or ''| entity}</td>
813- %else:
814- <td class="right_without_line">${ formatLang(line['amount']) or ''| entity}</td>
815- %endif
816- %if line['index']==0:
817- <td class="right_with_line">
818- %else:
819- <td class="right_without_line">
820- %endif
821- %if line['non_deductible']:
822- ${ line['non_deductible'] | entity} %
823- %endif
824- </td>
825- <td></td>
826+ ${ formatLang(object.amount) | entity}
827+ %endif
828+ </td>
829+ %if line['index']==0:
830+ <td class="right_with_line">${ (line['tax_code_name']) or ''| entity}</td>
831+ %else:
832+ <td class="right_without_line">${ (line['tax_code_name']) or ''| entity}</td>
833+ %endif
834+ %if line['index']==0:
835+ <td class="right_with_line">${ formatLang(line['amount'])| entity}</td>
836+ %else:
837+ <td class="right_without_line">${ formatLang(line['amount'])| entity}</td>
838+ %endif
839 </tr>
840 %endfor
841 %endfor
842@@ -134,34 +122,87 @@
843 </table>
844 <div style="page-break-inside: avoid;">
845 <br/>
846+ <% tax_code_list = tax_codes() %>
847+ <% tax_code_totals_list = tax_codes_totals() %>
848 <table style="width:100%; " border="1">
849 <tr style="border-style:ridge;border-width:5px">
850- <td colspan="4" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(data['form']['date_from'],date=True)| entity}</strong> al <strong>${formatLang(data['form']['date_to'],date=True)| entity}</strong></td>
851- </tr>
852- <tr>
853- <td rowspan="2" style="vertical-align:text-top;padding:10">
854- <table style="width:100%;">
855- <tr>
856- <th style="text-align:left">Descrizione</th>
857- <th style="text-align:right">Imponibile</th>
858- <th style="text-align:right">Imposta</th>
859- </tr>
860- %for tax_code in tax_codes :
861- <tr>
862- <td>${tax_code|entity}
863- </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['base'])|entity}
864- </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['amount']) or ''|entity}
865- </td>
866- </tr>
867- %endfor
868- </table>
869- </td><td style="padding:10">Totale operazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_operazioni'])|entity}</strong></p><br/></td>
870- <td colspan="2" style="padding:10">Totale imponibili:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_imponibili'])|entity}</strong></p><br/></td>
871- </tr>
872- <tr>
873- <td style="padding:10">Totale variazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_variazioni'])|entity}</strong></p><br/></td>
874- <td style="padding:10">Totale IVA Detraibile:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_iva'])|entity}</strong></p><br/></td>
875- <td style="padding:10">Totale IVA Indetraibile:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_iva_inded'])|entity}</strong></p><br/></td>
876+ <td colspan="3" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(start_date(),date=True)| entity}</strong> al <strong>${formatLang(end_date(),date=True)| entity}</strong></td>
877+ </tr>
878+ <tr>
879+ <td colspan="2" style="vertical-align:text-top;padding:10">
880+ <h3>Dettaglio</h3>
881+ <table style="width:100%;">
882+ <tr>
883+ <th style="text-align:left">Descrizione</th>
884+ <th style="text-align:right">Importo</th>
885+ </tr>
886+ %for tax_code_tuple in tax_code_list :
887+ % if not tax_code_tuple[2]:
888+ <tr>
889+ <td>${tax_code_tuple[0]|entity}
890+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
891+ </td>
892+ </tr>
893+ %endif
894+ %endfor
895+ </table>
896+ </td>
897+ <td style="vertical-align:text-top;padding:10">
898+ <h3>Totali</h3>
899+ <table style="width:100%;">
900+ <tr>
901+ <th style="text-align:left">Descrizione</th>
902+ <th style="text-align:right">Importo</th>
903+ </tr>
904+ %for tax_code_tuple in tax_code_totals_list :
905+ % if not tax_code_tuple[2]:
906+ <tr>
907+ <td>${tax_code_tuple[0]|entity}
908+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
909+ </td>
910+ </tr>
911+ %endif
912+ %endfor
913+ </table>
914+ </td>
915+ </tr>
916+ <tr>
917+ <td colspan="2" style="vertical-align:text-top;padding:10">
918+ <h3>Dettaglio imponibili</h3>
919+ <table style="width:100%;">
920+ <tr>
921+ <th style="text-align:left">Descrizione</th>
922+ <th style="text-align:right">Importo</th>
923+ </tr>
924+ %for tax_code_tuple in tax_code_list :
925+ % if tax_code_tuple[2]:
926+ <tr>
927+ <td>${tax_code_tuple[0]|entity}
928+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
929+ </td>
930+ </tr>
931+ %endif
932+ %endfor
933+ </table>
934+ </td>
935+ <td style="vertical-align:text-top;padding:10">
936+ <h3>Totali imponibili</h3>
937+ <table style="width:100%;">
938+ <tr>
939+ <th style="text-align:left">Descrizione</th>
940+ <th style="text-align:right">Importo</th>
941+ </tr>
942+ %for tax_code_tuple in tax_code_totals_list :
943+ % if tax_code_tuple[2]:
944+ <tr>
945+ <td>${tax_code_tuple[0]|entity}
946+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
947+ </td>
948+ </tr>
949+ %endif
950+ %endfor
951+ </table>
952+ </td>
953 </tr>
954 </table>
955 </div>
956
957=== modified file 'l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako'
958--- l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako 2013-01-08 23:01:16 +0000
959+++ l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako 2013-05-09 15:50:30 +0000
960@@ -19,16 +19,15 @@
961 <body>
962 <h2>Corrispettivi</h2>
963 <% setLang(objects[0].company_id.partner_id.lang or "en_US") %>
964- <table style="width:100%;" cellspacing="0">
965+ <table style="width:100%; font-size: small;" cellspacing="0">
966 <thead>
967 <tr>
968 <th class="left_without_line">Numero</th>
969 <th class="left_without_line">Data registrazione</th>
970- <th class="left_without_line">Causale</th>
971+ <th class="left_without_line">Sezionale</th>
972 <th class="right_without_line">Importo totale</th>
973- <th class="right_without_line">Imponibile</th>
974- <th class="right_without_line">% IVA</th>
975 <th class="right_without_line">Imposta</th>
976+ <th class="right_without_line">Importo</th>
977 <th></th>
978 </tr>
979 </thead>
980@@ -59,7 +58,7 @@
981 </td><td class="left_without_line">
982 %endif
983 %if line['index']==0:
984- Corrispettivi
985+ ${object.journal_id.name or ''| entity}
986 %endif
987 %if line['index']==0:
988 </td><td class="right_with_line">
989@@ -67,25 +66,19 @@
990 </td><td class="right_without_line">
991 %endif
992 %if line['index']==0:
993- ${ formatLang(line['amount_total']) | entity}
994+ ${ formatLang(object.amount) | entity}
995 %endif
996 </td>
997 %if line['index']==0:
998- <td class="right_with_line">${ formatLang(line['base']) or ''| entity}</td>
999- %else:
1000- <td class="right_without_line">${ formatLang(line['base']) or ''| entity}</td>
1001- %endif
1002- %if line['index']==0:
1003- <td class="right_with_line">${ line['tax_percentage'] or ''| entity}</td>
1004- %else:
1005- <td class="right_without_line">${ line['tax_percentage'] or ''| entity}</td>
1006- %endif
1007- %if line['index']==0:
1008- <td class="right_with_line">${ formatLang(line['amount']) or ''| entity}</td>
1009- %else:
1010- <td class="right_without_line">${ formatLang(line['amount']) or ''| entity}</td>
1011- %endif
1012- <td></td>
1013+ <td class="right_with_line">${ (line['tax_code_name']) or ''| entity}</td>
1014+ %else:
1015+ <td class="right_without_line">${ (line['tax_code_name']) or ''| entity}</td>
1016+ %endif
1017+ %if line['index']==0:
1018+ <td class="right_with_line">${ formatLang(line['amount'])| entity}</td>
1019+ %else:
1020+ <td class="right_without_line">${ formatLang(line['amount'])| entity}</td>
1021+ %endif
1022 </tr>
1023 %endfor
1024 %endfor
1025@@ -93,33 +86,87 @@
1026 </table>
1027 <div style="page-break-inside: avoid;">
1028 <br/>
1029+ <% tax_code_list = tax_codes() %>
1030+ <% tax_code_totals_list = tax_codes_totals() %>
1031 <table style="width:100%; " border="1">
1032 <tr style="border-style:ridge;border-width:5px">
1033- <td colspan="3" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(data['form']['date_from'],date=True)| entity}</strong> al <strong>${formatLang(data['form']['date_to'],date=True)| entity}</strong></td>
1034- </tr>
1035- <tr>
1036- <td rowspan="2" style="vertical-align:text-top;padding:10">
1037- <table style="width:100%;">
1038- <tr>
1039- <th style="text-align:left">Descrizione</th>
1040- <th style="text-align:right">Imponibile</th>
1041- <th style="text-align:right">Imposta</th>
1042- </tr>
1043- %for tax_code in tax_codes :
1044- <tr>
1045- <td>${tax_code|entity}
1046- </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['base'])|entity}
1047- </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['amount']) or ''|entity}
1048- </td>
1049- </tr>
1050- %endfor
1051- </table>
1052- </td><td style="padding:10">Totale operazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_operazioni'])|entity}</strong></p><br/></td>
1053- <td style="padding:10">Totale imponibili:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_imponibili'])|entity}</strong></p><br/></td>
1054- </tr>
1055- <tr>
1056- <td style="padding:10">Totale variazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_variazioni'])|entity}</strong></p><br/></td>
1057- <td style="padding:10">Totale IVA:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_iva'])|entity}</strong></p><br/></td>
1058+ <td colspan="3" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(start_date(),date=True)| entity}</strong> al <strong>${formatLang(end_date(),date=True)| entity}</strong></td>
1059+ </tr>
1060+ <tr>
1061+ <td colspan="2" style="vertical-align:text-top;padding:10">
1062+ <h3>Dettaglio</h3>
1063+ <table style="width:100%;">
1064+ <tr>
1065+ <th style="text-align:left">Descrizione</th>
1066+ <th style="text-align:right">Importo</th>
1067+ </tr>
1068+ %for tax_code_tuple in tax_code_list :
1069+ % if not tax_code_tuple[2]:
1070+ <tr>
1071+ <td>${tax_code_tuple[0]|entity}
1072+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
1073+ </td>
1074+ </tr>
1075+ %endif
1076+ %endfor
1077+ </table>
1078+ </td>
1079+ <td style="vertical-align:text-top;padding:10">
1080+ <h3>Totali</h3>
1081+ <table style="width:100%;">
1082+ <tr>
1083+ <th style="text-align:left">Descrizione</th>
1084+ <th style="text-align:right">Importo</th>
1085+ </tr>
1086+ %for tax_code_tuple in tax_code_totals_list :
1087+ % if not tax_code_tuple[2]:
1088+ <tr>
1089+ <td>${tax_code_tuple[0]|entity}
1090+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
1091+ </td>
1092+ </tr>
1093+ %endif
1094+ %endfor
1095+ </table>
1096+ </td>
1097+ </tr>
1098+ <tr>
1099+ <td colspan="2" style="vertical-align:text-top;padding:10">
1100+ <h3>Dettaglio imponibili</h3>
1101+ <table style="width:100%;">
1102+ <tr>
1103+ <th style="text-align:left">Descrizione</th>
1104+ <th style="text-align:right">Importo</th>
1105+ </tr>
1106+ %for tax_code_tuple in tax_code_list :
1107+ % if tax_code_tuple[2]:
1108+ <tr>
1109+ <td>${tax_code_tuple[0]|entity}
1110+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
1111+ </td>
1112+ </tr>
1113+ %endif
1114+ %endfor
1115+ </table>
1116+ </td>
1117+ <td style="vertical-align:text-top;padding:10">
1118+ <h3>Totali imponibili</h3>
1119+ <table style="width:100%;">
1120+ <tr>
1121+ <th style="text-align:left">Descrizione</th>
1122+ <th style="text-align:right">Importo</th>
1123+ </tr>
1124+ %for tax_code_tuple in tax_code_totals_list :
1125+ % if tax_code_tuple[2]:
1126+ <tr>
1127+ <td>${tax_code_tuple[0]|entity}
1128+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
1129+ </td>
1130+ </tr>
1131+ %endif
1132+ %endfor
1133+ </table>
1134+ </td>
1135 </tr>
1136 </table>
1137 </div>
1138
1139=== modified file 'l10n_it_vat_registries/templates/registro_iva_vendite.mako'
1140--- l10n_it_vat_registries/templates/registro_iva_vendite.mako 2013-01-08 23:01:16 +0000
1141+++ l10n_it_vat_registries/templates/registro_iva_vendite.mako 2013-05-09 15:50:30 +0000
1142@@ -19,7 +19,7 @@
1143 <body>
1144 <h2>Fatture Emesse</h2>
1145 <% setLang(objects[0].company_id.partner_id.lang or "en_US") %>
1146- <table style="width:100%;" cellspacing="0">
1147+ <table style="width:100%; font-size: small;" cellspacing="0">
1148 <thead>
1149 <tr>
1150 <th class="left_without_line">Data registrazione</th>
1151@@ -27,11 +27,10 @@
1152 <th class="left_without_line">Ragione sociale</th>
1153 <th class="left_without_line">Numero fattura</th>
1154 <th class="left_without_line">Data fattura</th>
1155- <th class="left_without_line">Causale</th>
1156+ <th class="left_without_line">Sezionale</th>
1157 <th class="right_without_line">Totale fattura</th>
1158- <th class="right_without_line">Imponibile</th>
1159- <th class="right_without_line">% IVA</th>
1160 <th class="right_without_line">Imposta</th>
1161+ <th class="right_without_line">Importo</th>
1162 <th></th>
1163 </tr>
1164 </thead>
1165@@ -78,7 +77,7 @@
1166 </td><td class="left_without_line">
1167 %endif
1168 %if line['index']==0:
1169- ${ formatLang(object.date,date=True) or '' | entity}
1170+ ${ formatLang(line['invoice_date'],date=True) or '' | entity}
1171 %endif
1172 %if line['index']==0:
1173 </td><td class="left_with_line">
1174@@ -86,11 +85,7 @@
1175 </td><td class="left_without_line">
1176 %endif
1177 %if line['index']==0:
1178- %if line['amount_total'] >= 0:
1179- Fattura
1180- %else:
1181- Nota di credito
1182- %endif
1183+ ${object.journal_id.name or ''| entity}
1184 %endif
1185 %if line['index']==0:
1186 </td><td class="right_with_line">
1187@@ -98,25 +93,19 @@
1188 </td><td class="right_without_line">
1189 %endif
1190 %if line['index']==0:
1191- ${ formatLang(line['amount_total']) | entity}
1192+ ${ formatLang(object.amount) | entity}
1193 %endif
1194 </td>
1195 %if line['index']==0:
1196- <td class="right_with_line">${ formatLang(line['base']) or ''| entity}</td>
1197- %else:
1198- <td class="right_without_line">${ formatLang(line['base']) or ''| entity}</td>
1199- %endif
1200- %if line['index']==0:
1201- <td class="right_with_line">${ line['tax_percentage'] or ''| entity}</td>
1202- %else:
1203- <td class="right_without_line">${ line['tax_percentage'] or ''| entity}</td>
1204- %endif
1205- %if line['index']==0:
1206- <td class="right_with_line">${ formatLang(line['amount']) or ''| entity}</td>
1207- %else:
1208- <td class="right_without_line">${ formatLang(line['amount']) or ''| entity}</td>
1209- %endif
1210- <td></td>
1211+ <td class="right_with_line">${ (line['tax_code_name']) or ''| entity}</td>
1212+ %else:
1213+ <td class="right_without_line">${ (line['tax_code_name']) or ''| entity}</td>
1214+ %endif
1215+ %if line['index']==0:
1216+ <td class="right_with_line">${ formatLang(line['amount'])| entity}</td>
1217+ %else:
1218+ <td class="right_without_line">${ formatLang(line['amount'])| entity}</td>
1219+ %endif
1220 </tr>
1221 %endfor
1222 %endfor
1223@@ -124,33 +113,87 @@
1224 </table>
1225 <div style="page-break-inside: avoid;">
1226 <br/>
1227+ <% tax_code_list = tax_codes() %>
1228+ <% tax_code_totals_list = tax_codes_totals() %>
1229 <table style="width:100%; " border="1">
1230 <tr style="border-style:ridge;border-width:5px">
1231- <td colspan="3" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(data['form']['date_from'],date=True)| entity}</strong> al <strong>${formatLang(data['form']['date_to'],date=True)| entity}</strong></td>
1232- </tr>
1233- <tr>
1234- <td rowspan="2" style="vertical-align:text-top;padding:10">
1235- <table style="width:100%;">
1236- <tr>
1237- <th style="text-align:left">Descrizione</th>
1238- <th style="text-align:right">Imponibile</th>
1239- <th style="text-align:right">Imposta</th>
1240- </tr>
1241- %for tax_code in tax_codes :
1242- <tr>
1243- <td>${tax_code|entity}
1244- </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['base'])|entity}
1245- </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['amount']) or ''|entity}
1246- </td>
1247- </tr>
1248- %endfor
1249- </table>
1250- </td><td style="padding:10">Totale operazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_operazioni'])|entity}</strong></p><br/></td>
1251- <td style="padding:10">Totale imponibili:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_imponibili'])|entity}</strong></p><br/></td>
1252- </tr>
1253- <tr>
1254- <td style="padding:10">Totale variazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_variazioni'])|entity}</strong></p><br/></td>
1255- <td style="padding:10">Totale IVA:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_iva'])|entity}</strong></p><br/></td>
1256+ <td colspan="3" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(start_date(),date=True)| entity}</strong> al <strong>${formatLang(end_date(),date=True)| entity}</strong></td>
1257+ </tr>
1258+ <tr>
1259+ <td colspan="2" style="vertical-align:text-top;padding:10">
1260+ <h3>Dettaglio</h3>
1261+ <table style="width:100%;">
1262+ <tr>
1263+ <th style="text-align:left">Descrizione</th>
1264+ <th style="text-align:right">Importo</th>
1265+ </tr>
1266+ %for tax_code_tuple in tax_code_list :
1267+ % if not tax_code_tuple[2]:
1268+ <tr>
1269+ <td>${tax_code_tuple[0]|entity}
1270+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
1271+ </td>
1272+ </tr>
1273+ %endif
1274+ %endfor
1275+ </table>
1276+ </td>
1277+ <td style="vertical-align:text-top;padding:10">
1278+ <h3>Totali</h3>
1279+ <table style="width:100%;">
1280+ <tr>
1281+ <th style="text-align:left">Descrizione</th>
1282+ <th style="text-align:right">Importo</th>
1283+ </tr>
1284+ %for tax_code_tuple in tax_code_totals_list :
1285+ % if not tax_code_tuple[2]:
1286+ <tr>
1287+ <td>${tax_code_tuple[0]|entity}
1288+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
1289+ </td>
1290+ </tr>
1291+ %endif
1292+ %endfor
1293+ </table>
1294+ </td>
1295+ </tr>
1296+ <tr>
1297+ <td colspan="2" style="vertical-align:text-top;padding:10">
1298+ <h3>Dettaglio imponibili</h3>
1299+ <table style="width:100%;">
1300+ <tr>
1301+ <th style="text-align:left">Descrizione</th>
1302+ <th style="text-align:right">Importo</th>
1303+ </tr>
1304+ %for tax_code_tuple in tax_code_list :
1305+ % if tax_code_tuple[2]:
1306+ <tr>
1307+ <td>${tax_code_tuple[0]|entity}
1308+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
1309+ </td>
1310+ </tr>
1311+ %endif
1312+ %endfor
1313+ </table>
1314+ </td>
1315+ <td style="vertical-align:text-top;padding:10">
1316+ <h3>Totali imponibili</h3>
1317+ <table style="width:100%;">
1318+ <tr>
1319+ <th style="text-align:left">Descrizione</th>
1320+ <th style="text-align:right">Importo</th>
1321+ </tr>
1322+ %for tax_code_tuple in tax_code_totals_list :
1323+ % if tax_code_tuple[2]:
1324+ <tr>
1325+ <td>${tax_code_tuple[0]|entity}
1326+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
1327+ </td>
1328+ </tr>
1329+ %endif
1330+ %endfor
1331+ </table>
1332+ </td>
1333 </tr>
1334 </table>
1335 </div>
1336
1337=== modified file 'l10n_it_vat_registries/wizard/__init__.py'
1338--- l10n_it_vat_registries/wizard/__init__.py 2013-01-29 22:08:50 +0000
1339+++ l10n_it_vat_registries/wizard/__init__.py 2013-05-09 15:50:30 +0000
1340@@ -1,7 +1,7 @@
1341 # -*- coding: utf-8 -*-
1342 ##############################################################################
1343 #
1344-# Copyright (C) 2011 Associazione OpenERP Italia
1345+# Copyright (C) 2011-2013 Associazione OpenERP Italia
1346 # (<http://www.openerp-italia.org>).
1347 #
1348 # This program is free software: you can redistribute it and/or modify
1349@@ -12,7 +12,7 @@
1350 # This program is distributed in the hope that it will be useful,
1351 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1352 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1353-# GNU General Public License for more details.
1354+# GNU Affero General Public License for more details.
1355 #
1356 # You should have received a copy of the GNU Affero General Public License
1357 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1358
1359=== modified file 'l10n_it_vat_registries/wizard/print_registro_iva.py'
1360--- l10n_it_vat_registries/wizard/print_registro_iva.py 2013-01-29 22:08:50 +0000
1361+++ l10n_it_vat_registries/wizard/print_registro_iva.py 2013-05-09 15:50:30 +0000
1362@@ -25,79 +25,64 @@
1363
1364 class wizard_registro_iva(osv.osv_memory):
1365
1366+ def _get_period(self, cr, uid, context=None):
1367+ ctx = dict(context or {}, account_period_prefer_normal=True)
1368+ period_ids = self.pool.get('account.period').find(cr, uid, context=ctx)
1369+ return period_ids
1370+
1371 _name = "wizard.registro.iva"
1372 _columns = {
1373- 'date_from': fields.date('From date', required=True),
1374- 'date_to': fields.date('To date', required=True),
1375+ 'period_ids': fields.many2many('account.period', 'registro_iva_periods_rel', 'period_id', 'registro_id', 'Periods', help='Select periods you want retrieve documents from', required=True),
1376 'type': fields.selection([
1377 ('customer', 'Customer Invoices'),
1378 ('supplier', 'Supplier Invoices'),
1379 ('corrispettivi', 'Corrispettivi'),
1380 ], 'Layout', required=True),
1381 'journal_ids': fields.many2many('account.journal', 'registro_iva_journals_rel', 'journal_id', 'registro_id', 'Journals', help='Select journals you want retrieve documents from', required=True),
1382+ 'tax_sign': fields.float('Tax amount sign',
1383+ help="Use -1 you have negative tax amounts and you want to print them prositive"),
1384 'message': fields.char('Message', size=64, readonly=True),
1385+ 'fiscal_page_base': fields.integer('Last printed page', required=True),
1386 }
1387 _defaults = {
1388 'type': 'customer',
1389- 'date_from': lambda * a: time.strftime('%Y-%m-%d'),
1390- 'date_to': lambda * a: time.strftime('%Y-%m-%d'),
1391- #'journal_ids': lambda s, cr, uid, c: s.pool.get('account.journal').search(cr, uid, []),
1392+ 'period_ids': _get_period,
1393+ 'tax_sign': 1.0,
1394+ 'fiscal_page_base': 0,
1395 }
1396-
1397- def counterparts_number(self, move_line):
1398- counter = 0
1399- if not move_line.credit:
1400- for line in move_line.move_id.line_id:
1401- if line.credit:
1402- counter += 1
1403- elif not move_line.debit:
1404- for line in move_line.move_id.line_id:
1405- if line.debit:
1406- counter += 1
1407- return counter
1408
1409 def print_registro(self, cr, uid, ids, context=None):
1410- move_ids = []
1411- wizard = self.read(cr, uid, ids)[0]
1412- move_line_obj = self.pool.get('account.move.line')
1413- tax_pool = self.pool.get('account.tax')
1414- search_list = []
1415- search_list = [
1416- ('journal_id', 'in', wizard['journal_ids']),
1417- ('move_id.date', '<=', wizard['date_to']),
1418- ('move_id.date', '>=', wizard['date_from']),
1419- ('move_id.state', '=', 'posted'),
1420- ('tax_code_id', '!=', False),
1421- ]
1422- move_line_ids = move_line_obj.search(cr, uid, search_list, order='date')
1423 if context is None:
1424 context = {}
1425- for move_line in move_line_obj.browse(cr, uid, move_line_ids):
1426- # verifico che sia coinvolto un conto imposta legato ad un'imposta tramite conto standard o conto refund
1427- if move_line.tax_code_id.tax_ids or move_line.tax_code_id.ref_tax_ids:
1428- if move_line.tax_code_id.tax_ids:
1429- if not tax_pool._have_same_rate(move_line.tax_code_id.tax_ids):
1430- raise osv.except_osv(_('Error'), _('Taxes %s have different rates')
1431- % str(move_line.tax_code_id.tax_ids))
1432- if move_line.tax_code_id.ref_tax_ids:
1433- if not tax_pool._have_same_rate(move_line.tax_code_id.ref_tax_ids):
1434- raise osv.except_osv(_('Error'), _('Taxes %s have different rates')
1435- % str(move_line.tax_code_id.ref_tax_ids))
1436- # controllo che ogni tax code abbia una e una sola imposta
1437- ''' non posso farlo per via dell IVA inclusa nel prezzo
1438- if len(move_line.tax_code_id.tax_ids) != 1:
1439- raise osv.except_osv(_('Error'), _('Wrong tax configuration for tax code %s')
1440- % move_line.tax_code_id.name)
1441- '''
1442- if move_line.move_id.id not in move_ids:
1443- move_ids.append(move_line.move_id.id)
1444+ wizard = self.browse(cr, uid, ids)[0]
1445+ move_obj = self.pool.get('account.move')
1446+ obj_model_data = self.pool.get('ir.model.data')
1447+ move_ids = move_obj.search(cr, uid, [
1448+ ('journal_id', 'in', [j.id for j in wizard.journal_ids]),
1449+ ('period_id', 'in', [p.id for p in wizard.period_ids]),
1450+ ('state', '=', 'posted'),
1451+ ], order='date')
1452 if not move_ids:
1453 self.write(cr, uid, ids, {'message': _('No documents found in the current selection')})
1454- return True
1455+ model_data_ids = obj_model_data.search(cr, uid, [('model','=','ir.ui.view'), ('name','=','wizard_registro_iva')])
1456+ resource_id = obj_model_data.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id']
1457+ return {
1458+ 'name': _('No documents'),
1459+ 'res_id': ids[0],
1460+ 'view_type': 'form',
1461+ 'view_mode': 'form',
1462+ 'res_model': 'wizard.registro.iva',
1463+ 'views': [(resource_id,'form')],
1464+ 'context': context,
1465+ 'type': 'ir.actions.act_window',
1466+ 'target': 'new',
1467+ }
1468 datas = {'ids': move_ids}
1469 datas['model'] = 'account.move'
1470- datas['form'] = wizard
1471- datas['move_ids'] = move_ids
1472+ datas['fiscal_page_base'] = wizard.fiscal_page_base
1473+ datas['period_ids'] = [p.id for p in wizard.period_ids]
1474+ datas['layout'] = wizard['type']
1475+ datas['tax_sign'] = wizard['tax_sign']
1476 res= {
1477 'type': 'ir.actions.report.xml',
1478 'datas': datas,
1479@@ -110,4 +95,11 @@
1480 res['report_name'] = 'registro_iva_corrispettivi'
1481 return res
1482
1483-wizard_registro_iva()
1484+ def on_type_changed(self, cr, uid, ids, j_type, context=None):
1485+ res={}
1486+ if j_type:
1487+ if j_type == 'supplier':
1488+ res['value'] = {'tax_sign': -1}
1489+ else:
1490+ res['value'] = {'tax_sign': 1}
1491+ return res
1492
1493=== modified file 'l10n_it_vat_registries/wizard/print_registro_iva.xml'
1494--- l10n_it_vat_registries/wizard/print_registro_iva.xml 2013-01-08 23:01:16 +0000
1495+++ l10n_it_vat_registries/wizard/print_registro_iva.xml 2013-05-09 15:50:30 +0000
1496@@ -7,16 +7,23 @@
1497 <field name="model">wizard.registro.iva</field>
1498 <field name="type">form</field>
1499 <field name="arch" type="xml">
1500- <form string="Tax Journal">
1501- <field name="date_from"/>
1502- <field name="date_to"/>
1503- <field name="type" colspan="4"/>
1504- <separator string="Journals" colspan="4"/>
1505- <field name="journal_ids" colspan="4" nolabel="1" height="250"/>
1506- <button icon="gtk-cancel" special="cancel" string="Cancel"/>
1507- <button icon="gtk-ok" name="print_registro" string="Print" type="object"/>
1508- <newline/>
1509- <field name="message" nolabel="1" colspan="4"/>
1510+ <form string="Tax Journal" version="7.0">
1511+ <group>
1512+ <field name="type" on_change="on_type_changed(type)"/>
1513+ <field name="tax_sign"/>
1514+ <field name="fiscal_page_base"/>
1515+ <separator string="Periods" colspan="4"/>
1516+ <field name="period_ids" colspan="4" nolabel="1" height="250"/>
1517+ <separator string="Journals" colspan="4"/>
1518+ <field name="journal_ids" colspan="4" nolabel="1" height="250" domain="[('type', 'in', ('sale','purchase','sale_refund','purchase_refund'))]"/>
1519+ <newline/>
1520+ <field name="message" nolabel="1" colspan="4"/>
1521+ </group>
1522+ <footer>
1523+ <button string="Print" name="print_registro" type="object" class="oe_highlight"/>
1524+ or
1525+ <button string="Cancel" class="oe_link" special="cancel"/>
1526+ </footer>
1527 </form>
1528 </field>
1529 </record>

Subscribers

People subscribed via source and target branches