← Back to team overview

openobject-italia-core-devs team mailing list archive

lp:~elbati/openobject-italia/7-l10n_it_vat_registries_simplified into lp:openobject-italia/7.0

 

Lorenzo Battistini - Agile BG has proposed merging lp:~elbati/openobject-italia/7-l10n_it_vat_registries_simplified into lp:openobject-italia/7.0.

Requested reviews:
  OpenERP Italia core devs (openobject-italia-core-devs)

For more details, see:
https://code.launchpad.net/~elbati/openobject-italia/7-l10n_it_vat_registries_simplified/+merge/162188
-- 
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.
=== modified file 'l10n_it_vat_registries/__init__.py'
--- l10n_it_vat_registries/__init__.py	2013-01-29 22:08:50 +0000
+++ l10n_it_vat_registries/__init__.py	2013-05-02 17:34:30 +0000
@@ -20,5 +20,4 @@
 ##############################################################################
 
 import wizard
-import account
 import invoice

=== modified file 'l10n_it_vat_registries/__openerp__.py'
--- l10n_it_vat_registries/__openerp__.py	2013-02-18 19:37:15 +0000
+++ l10n_it_vat_registries/__openerp__.py	2013-05-02 17:34:30 +0000
@@ -33,7 +33,6 @@
         ],
     "update_xml" : [
         'reports.xml',
-        'account_view.xml',
         'wizard/print_registro_iva.xml',
         ],
     "demo_xml" : [],

=== removed file 'l10n_it_vat_registries/account.py'
--- l10n_it_vat_registries/account.py	2013-01-29 22:08:50 +0000
+++ l10n_it_vat_registries/account.py	1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    Copyright (C) 2011-2012 Associazione OpenERP Italia
-#    (<http://www.openerp-italia.org>).
-#    Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
-#    Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as published
-#    by the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU Affero General Public License for more details.
-#
-#    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-
-from osv import fields, osv
-from tools.translate import _
-
-
-class account_tax(osv.osv):
-
-    _inherit = 'account.tax'
-    _columns = {
-        'exclude_from_registries': fields.boolean(
-            'Exclude from VAT registries'),
-        'base_tax_ids': fields.one2many(
-            'account.tax', 'base_code_id', 'Base Taxes'),  # serve ancora?
-        }
-    _sql_constraints = [
-        ('name_uniq', 'UNIQUE(name)', 'The tax name must be unique!'),
-    ]
-
-    def get_account_tax(self, inv_tax):
-        if inv_tax.tax_code_id:
-            return self.get_account_tax_by_tax_code(inv_tax.tax_code_id)
-        if inv_tax.base_code_id:
-            return self.get_account_tax_by_base_code(inv_tax.base_code_id)
-        raise osv.except_osv(_('Error'),
-            _('No tax codes for invoice tax %s') % str(inv_tax.name))
-

=== removed file 'l10n_it_vat_registries/account_view.xml'
--- l10n_it_vat_registries/account_view.xml	2013-01-08 23:01:16 +0000
+++ l10n_it_vat_registries/account_view.xml	1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-    <data>
-
-        <record id="view_tax_form" model="ir.ui.view">
-            <field name="name">account.tax.form</field>
-            <field name="model">account.tax</field>
-            <field name="type">form</field>
-            <field name="inherit_id" ref="account.view_tax_form"></field>
-            <field name="arch" type="xml">
-                <field name="active" position="after">
-                    <field name="exclude_from_registries"/>
-                </field>
-            </field>
-        </record>
-    </data>
-</openerp>

=== modified file 'l10n_it_vat_registries/invoice.py'
--- l10n_it_vat_registries/invoice.py	2013-04-24 10:14:49 +0000
+++ l10n_it_vat_registries/invoice.py	2013-05-02 17:34:30 +0000
@@ -22,311 +22,57 @@
 import time
 from report import report_sxw
 from tools.translate import _
-from decimal import *
-import netsvc
+import logging
+
+_logger = logging.getLogger(__name__)
 
 class Parser(report_sxw.rml_parse):
-
-    logger = netsvc.Logger()
-
-    def _get_partner_type(self, move_line):
-        partner_type = ''
-        for line in move_line.move_id.line_id:
-            if line.account_id.type == 'payable' or line.account_id.type == 'receivable':
-                if not partner_type:
-                    partner_type = line.account_id.type
-                elif partner_type != line.account_id.type:
-                    raise Exception(
-                        _('The move %s has different partner account type') % move_line.move_id.name)
-        return partner_type
-
-    def _move_total(self, move_line):
-        partner_type = self._get_partner_type(move_line)
-        total = 0.0
-        for line in move_line.move_id.line_id:
-            if line.account_id.type == partner_type:
-                total += (line.debit or line.credit)
-        return total
-
-    # Metto al tax code il segno dell'importo dell'imposta.
-    # Il tax code ha l'importo in valuta base, ma ha segno negativo per l'IVA a credito (da stampare positiva)
-    # e per le note di credito (da stampare negative)
-    def _get_amount_with_sign(self, tax_code_amount, amount):
-        return abs(tax_code_amount) * cmp(amount, 0)
-
-    def _is_refund(self, move_line):
-        if self._get_partner_type(move_line) == 'receivable' and move_line.debit > move_line.credit:
-            return True
-        if self._get_partner_type(move_line) == 'payable' and move_line.debit < move_line.credit:
-            return True
-
-    def _get_line_amount_with_sign(self, move_line):
-        if self._get_partner_type(move_line) == 'receivable':
-            return self._get_amount_with_sign(move_line.tax_amount, move_line.credit - move_line.debit)
-        if self._get_partner_type(move_line) == 'payable':
-            return self._get_amount_with_sign(move_line.tax_amount, move_line.debit - move_line.credit)
-
-    # in valuta base
-    def _get_invoice_amount_total(self, invoice):
-        total = 0.0
-        for inv_tax in invoice.tax_line:
-            total += self._get_amount_with_sign(inv_tax.base_amount, inv_tax.base) \
-                + self._get_amount_with_sign(inv_tax.tax_amount, inv_tax.amount)
-        return total
-
-    # in valuta base
-    def _get_invoice_amount_untaxed(self, invoice):
-        total = 0.0
-        for inv_tax in invoice.tax_line:
-            total += self._get_amount_with_sign(inv_tax.base_amount, inv_tax.base)
-        return total
+    
+    def _tax_amounts_by_code(self, move):
+        res={}
+        for move_line in move.line_id:
+            if move_line.tax_code_id and move_line.tax_amount:
+                if not res.get(move_line.tax_code_id.id):
+                    res[move_line.tax_code_id.id] = 0.0
+                res[move_line.tax_code_id.id] += move_line.tax_amount
+        return res
 
     def _get_tax_lines(self, move):
         res=[]
-        tax_obj = self.pool.get('account.tax')
-        cur_pool = self.pool.get('res.currency')
-        inv_pool = self.pool.get('account.invoice')
+        tax_code_obj=self.pool.get('account.tax.code')
         # index è usato per non ripetere la stampa dei dati fattura quando ci sono più codici IVA
         index=0
-        totale_iva = 0.0
-        totale_iva_inded = 0.0
-        invoice_amount_total = 0.0
-        invoice_amount_untaxed = 0.0
-        related_invoices = []
-
-        ''' riusciamo a essere sempre indipendenti dalle fatture?
-        # se c'è l'oggetto fattura, utilizzo il calcolo su fattura
-        for move_line in move.line_id:
-            if move_line.invoice and move_line.invoice.id not in related_invoices:
-                related_invoices.append(move_line.invoice.id)
-        '''
-
-        if related_invoices:
-            for invoice_id in related_invoices:
-                return self._get_tax_lines_by_invoice(inv_pool.browse(self.cr, self.uid, invoice_id))
-
-        for move_line in move.line_id:
-            tax_item = {}
-            if move_line.tax_code_id and move_line.tax_code_id.tax_ids:
-                # Nel wizard ho già controllato che le eventuali diverse
-                # imposte abbiamo la stessa aliquota.
-                # Le diverse imposte devono comunque usare gli stessi tax code
-                main_tax = tax_obj.get_main_tax(move_line.tax_code_id.tax_ids[0])
-                if main_tax.exclude_from_registries:
-                    self.logger.notifyChannel("l10n_it_vat_registries", netsvc.LOG_INFO,
-                        _('The tax %s is excluded from registries') % main_tax.name)
-                    continue
-                # sommo gli imponibili relativi all'imposta corrente
-                base_amount = 0.0
-                for line in move_line.move_id.line_id:
-                    if line.tax_code_id.id == main_tax.base_code_id.id:
-                        base_amount += self._get_line_amount_with_sign(line)
-                if base_amount and main_tax.amount:
-                    actual_tax_amount = base_amount * main_tax.amount
-                else:
-                    actual_tax_amount = move_line.tax_amount
-                actual_tax_amount = cur_pool.round(
-                    self.cr, self.uid, move.company_id.currency_id,
-                    actual_tax_amount)
-                # calcolo % indetraibile
-                non_deductible = 0.0
-                if abs(actual_tax_amount) != abs(move_line.tax_amount):
-                    non_deductible = 100
-                    if move_line.tax_amount:
-                        non_deductible = 100 - abs((
-                            move_line.tax_amount * 100.0) / actual_tax_amount)
-                        non_deductible = cur_pool.round(
-                            self.cr, self.uid, move.company_id.currency_id,
-                            non_deductible)
-                # calcolo il totale dell'operazione
-                invoice_amount_total = self._move_total(move_line)
-                if self._is_refund(move_line):
-                    invoice_amount_total = - invoice_amount_total
-                str_non_deductible = str(non_deductible).split('.')[0]
-                tax_item = {
-                    'tax_percentage': main_tax.amount and str(
-                        main_tax.amount * 100).split('.')[0] or
-                        move_line.tax_code_id.name,
-                    'tax_code_name': move_line.tax_code_id.name,
-                    'base': base_amount,
-                    'amount': actual_tax_amount,
-                    'non_deductible': str_non_deductible != '0' and
-                        str_non_deductible or '',
-                    'index': index,
-                    'amount_total': invoice_amount_total,
-                    }
-                res.append(tax_item)
-                iva = cur_pool.round(
-                    self.cr, self.uid, move.company_id.currency_id,
-                    (actual_tax_amount * (100 - non_deductible) * 0.01))
-                iva_inded = cur_pool.round(
-                    self.cr, self.uid, move.company_id.currency_id,
-                    (actual_tax_amount * non_deductible * 0.01))
-                tax_difference= (iva + iva_inded) - actual_tax_amount
-                # se risulta un'eccedenza, la tolgo dalla parte detraibile
-                if tax_difference > 0:
-                    iva = iva - tax_difference
-                # se risulta una mancanza, la aggiungo alla parte indetraibile
-                elif tax_difference < 0:
-                    iva_inded = iva_inded + tax_difference
-                totale_iva += iva
-                invoice_amount_untaxed += base_amount
-                totale_iva_inded += iva_inded
-                index += 1
-
-            if tax_item:
-                if tax_item['tax_code_name'] not in self.localcontext[
-                    'tax_codes']:
-                    self.localcontext['tax_codes'][tax_item[
-                        'tax_code_name']] = {
-                        'base': tax_item['base'],
-                        'amount': tax_item['amount'],
-                        }
-                else:
-                    self.localcontext['tax_codes'][tax_item[
-                        'tax_code_name']]['base'] += tax_item['base']
-                    self.localcontext['tax_codes'][tax_item[
-                        'tax_code_name']]['amount'] += tax_item['amount']
-
-        self.localcontext['totali'][
-            'totale_operazioni'] += invoice_amount_total
-        self.localcontext['totali'][
-            'totale_imponibili'] += invoice_amount_untaxed
-        self.localcontext['totali']['totale_iva'] += totale_iva
-        self.localcontext['totali']['totale_iva_inded'] += totale_iva_inded
-
+        invoice = False
+        for move_line in move.line_id:
+            if move_line.invoice:
+                if invoice and invoice.id != move_line.invoice.id:
+                    raise Exception(_("Move %s contains different invoices") % move.name)
+                invoice = move_line.invoice
+        amounts_by_code = self._tax_amounts_by_code(move)
+        for tax_code_id in amounts_by_code:
+            tax_code = tax_code_obj.browse(self.cr, self.uid, tax_code_id)
+            tax_item = {
+                'tax_code_name': tax_code.name,
+                'amount': amounts_by_code[tax_code_id],
+                'index': index,
+                'invoice_date': (invoice and invoice.date_invoice
+                    or move.date or ''),
+                }
+            res.append(tax_item)
+            index += 1
         return res
-
-    def _get_tax_lines_by_invoice(self, invoice):
+    
+    def _get_tax_codes(self,move):
+        tax_code_obj = self.pool.get('account.tax.code')
+        tax_code_ids = tax_code_obj.search(self.cr, self.uid, [
+            ('child_ids','=', False),
+            ])
         res=[]
-        tax_obj = self.pool.get('account.tax')
-        # index è usato per non ripetere la stampa dei dati fattura quando ci sono più codici IVA
-        index = 0
-        totale_iva = 0.0
-        totale_iva_inded = 0.0
-        invoice_amount_total = 0.0
-        invoice_amount_untaxed = 0.0
-        for inv_tax in invoice.tax_line:
-            tax_item = {}
-            if inv_tax.base_code_id and inv_tax.tax_code_id:
-                account_tax = tax_obj.get_account_tax(inv_tax)
-                if account_tax.exclude_from_registries:
-                    self.logger.notifyChannel("l10n_it_vat_registries",
-                        netsvc.LOG_INFO, _(
-                        'The tax %s is excluded from registries')
-                        % account_tax.name)
-                    continue
-                account_tax_amount = account_tax.amount
-                invoice_amount_total = self._get_invoice_amount_total(invoice)
-                invoice_amount_untaxed = self._get_invoice_amount_untaxed(
-                    invoice)
-                amount = self._get_amount_with_sign(inv_tax.tax_amount,
-                    inv_tax.amount)
-                base = self._get_amount_with_sign(inv_tax.base_amount,
-                    inv_tax.base)
-                # calcolo le note di credito con segno invertito
-                if invoice.type in ('in_refund', 'out_refund'):
-                    amount = -amount
-                    base = -base
-                    invoice_amount_untaxed = -invoice_amount_untaxed
-                    invoice_amount_total = -invoice_amount_total
-                tax_item = {
-                    'tax_percentage': account_tax_amount and str(
-                        account_tax_amount * 100).split('.')[0] or
-                        inv_tax.tax_code_id.name,
-                    'base': base,
-                    'amount': amount,  # in valuta base
-                    'non_deductible': 0.0,
-                    'index': index,
-                    'amount_total': invoice_amount_total,
-                    }
-                res.append(tax_item)
-                totale_iva += amount
-                index += 1
-            # Se non c'è il tax code imponibile, cerco la tassa relativa alla parte non deducibile
-            elif inv_tax.tax_code_id:
-                tax = tax_obj.get_main_tax(tax_obj.get_account_tax(inv_tax))
-                if tax.exclude_from_registries:
-                    self.logger.notifyChannel("l10n_it_vat_registries",
-                        netsvc.LOG_INFO,
-                        _('The tax %s is excluded from registries') % tax.name)
-                    continue
-                for inv_tax_2 in invoice.tax_line:
-                    if inv_tax_2.base_code_id and not inv_tax_2.tax_code_id:
-                        base_tax = tax_obj.get_main_tax(
-                            tax_obj.get_account_tax(inv_tax_2))
-                        # Se hanno la stessa tassa
-                        if base_tax.id == tax.id:
-                            # Uso il valore assoluto perchè riferendosi
-                            # alla stessa imposta non ci possono essere
-                            # segni differenti
-                            non_deductible = (abs(inv_tax_2.base_amount) /
-                                (abs(inv_tax.base_amount) + abs(
-                                    inv_tax_2.base_amount)) * 100)
-                            invoice_amount_total = \
-                                self._get_invoice_amount_total(invoice)
-                            invoice_amount_untaxed = \
-                                self._get_invoice_amount_untaxed(invoice)
-                            amount = self._get_amount_with_sign(
-                                inv_tax.tax_amount, inv_tax.amount)
-                            base = self._get_amount_with_sign(
-                                inv_tax.base_amount, inv_tax.base)
-                            amount2 = self._get_amount_with_sign(
-                                inv_tax_2.tax_amount, inv_tax_2.amount)
-                            base2 = self._get_amount_with_sign(
-                                inv_tax_2.base_amount, inv_tax_2.base)
-                            # calcolo le note di credito con segno invertito
-                            if invoice.type in ('in_refund', 'out_refund'):
-                                amount = -amount
-                                base = -base
-                                amount2 = -amount2
-                                base2 = -base2
-                                invoice_amount_untaxed = \
-                                    -invoice_amount_untaxed
-                                invoice_amount_total = -invoice_amount_total
-                            tax_item = {
-                                'tax_percentage': base_tax.amount and str(
-                                    base_tax.amount * 100).split('.')[0] or
-                                    inv_tax.tax_code_id.name,
-                                'base': base + base2,
-                                'amount': amount + amount2,
-                                'non_deductible': non_deductible and str(
-                                    non_deductible).split('.')[0] or '',
-                                'index': index,
-                                'amount_total': invoice_amount_total,
-                                }
-                            res.append(tax_item)
-                            totale_iva += amount
-                            totale_iva_inded += amount2
-                            index += 1
-                            break
-            elif not inv_tax.tax_code_id and not inv_tax.base_code_id:
-                self.logger.notifyChannel("l10n_it_vat_registries",
-                    netsvc.LOG_INFO,
-                    _('The tax %s has no tax codes') % inv_tax.name)
-                continue
-            if tax_item:
-                if tax_item['tax_percentage'] not in self.localcontext[
-                    'tax_codes']:
-                    self.localcontext['tax_codes'][tax_item[
-                        'tax_percentage']] = {
-                        'base': tax_item['base'],
-                        'amount': tax_item['amount'],
-                        }
-                else:
-                    self.localcontext['tax_codes'][tax_item[
-                        'tax_percentage']]['base'] += tax_item['base']
-                    self.localcontext['tax_codes'][tax_item[
-                        'tax_percentage']]['amount'] += tax_item['amount']
-
-        self.localcontext['totali'][
-            'totale_operazioni'] += invoice_amount_total
-        self.localcontext['totali'][
-            'totale_imponibili'] += invoice_amount_untaxed
-# da analizzare           self.totale_variazioni += invoice.amount_total
-        self.localcontext['totali']['totale_iva'] += totale_iva
-        self.localcontext['totali']['totale_iva_inded'] += totale_iva_inded
-
+        for tax_code in tax_code_obj.browse(self.cr, self.uid, tax_code_ids, context={
+            'period_id': move.period_id.id,
+            }):
+            if tax_code.sum_period:
+                res.append((tax_code.name,tax_code.sum_period))
         return res
 
     def __init__(self, cr, uid, name, context):
@@ -334,14 +80,7 @@
         self.localcontext.update({
             'time': time,
             'tax_lines': self._get_tax_lines,
-            'totali': {
-                'totale_operazioni': 0.0,
-                'totale_imponibili': 0.0,
-                'totale_variazioni': 0.0,
-                'totale_iva': 0.0,
-                'totale_iva_inded': 0.0,
-                },
-            'tax_codes': {},
+            'tax_codes': self._get_tax_codes,
         })
 
 

=== modified file 'l10n_it_vat_registries/templates/registro_iva_acquisti.mako'
--- l10n_it_vat_registries/templates/registro_iva_acquisti.mako	2013-01-08 23:01:16 +0000
+++ l10n_it_vat_registries/templates/registro_iva_acquisti.mako	2013-05-02 17:34:30 +0000
@@ -27,12 +27,10 @@
             <th class="left_without_line">Ragione sociale</th>
             <th class="left_without_line">Numero fattura</th>
             <th class="left_without_line">Data fattura</th>
-            <th class="left_without_line">Causale</th>
+            <th class="left_without_line">Sezionale</th>
             <th class="right_without_line">Totale fattura</th>
-            <th class="right_without_line">Imponibile</th>
-            <th class="right_without_line">% IVA</th>
             <th class="right_without_line">Imposta</th>
-            <th class="right_without_line">% inded.</th>
+            <th class="right_without_line">Importo</th>
             <th></th>
         </tr>
         </thead>
@@ -79,7 +77,7 @@
                     </td><td class="left_without_line">
                 %endif
                 %if line['index']==0:
-                    ${ formatLang(object.date,date=True) or '' | entity}
+                    ${ formatLang(line['invoice_date'],date=True) or '' | entity}
                 %endif
                 %if line['index']==0:
                     </td><td class="left_with_line">
@@ -87,11 +85,7 @@
                     </td><td class="left_without_line">
                 %endif
                 %if line['index']==0:
-                    %if line['amount_total'] >= 0:
-                        Fattura
-                    %else:
-                        Nota di credito
-                    %endif
+                    ${object.journal_id.name or ''| entity}
                 %endif
                 %if line['index']==0:
                     </td><td class="right_with_line">
@@ -99,34 +93,19 @@
                     </td><td class="right_without_line">
                 %endif
                 %if line['index']==0:
-                    ${ formatLang(line['amount_total']) | entity}
-                %endif
-                </td>
-                %if line['index']==0:
-                    <td class="right_with_line">${ formatLang(line['base'])  or ''| entity}</td>
-                %else:
-                    <td class="right_without_line">${ formatLang(line['base'])  or ''| entity}</td>
-                %endif
-                %if line['index']==0:
-                    <td class="right_with_line">${ line['tax_percentage'] or ''| entity}</td>
-                %else:
-                    <td class="right_without_line">${ line['tax_percentage'] or ''| entity}</td>
-                %endif
-                %if line['index']==0:
-                    <td class="right_with_line">${ formatLang(line['amount'])  or ''| entity}</td>
-                %else:
-                    <td class="right_without_line">${ formatLang(line['amount'])  or ''| entity}</td>
-                %endif
-                %if line['index']==0:
-                    <td class="right_with_line">
-                %else:
-                    <td class="right_without_line">
-                %endif
-                %if line['non_deductible']:
-                    ${ line['non_deductible'] | entity} %
-                %endif
-                </td>
-                <td></td>
+                    ${ formatLang(object.amount) | entity}
+                %endif
+                </td>
+                %if line['index']==0:
+                    <td class="right_with_line">${ (line['tax_code_name'])  or ''| entity}</td>
+                %else:
+                    <td class="right_without_line">${ (line['tax_code_name'])  or ''| entity}</td>
+                %endif
+                %if line['index']==0:
+                    <td class="right_with_line">${ formatLang(line['amount'])| entity}</td>
+                %else:
+                    <td class="right_without_line">${ formatLang(line['amount'])| entity}</td>
+                %endif
                 </tr>
             %endfor
         %endfor
@@ -136,32 +115,25 @@
         <br/>
         <table style="width:100%;  " border="1">
             <tr style="border-style:ridge;border-width:5px">
-                <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>
+                <td colspan="3" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(objects[0].period_id.date_start,date=True)| entity}</strong> al <strong>${formatLang(objects[0].period_id.date_stop,date=True)| entity}</strong></td>
             </tr>
             <tr>
                 <td rowspan="2" style="vertical-align:text-top;padding:10">
                     <table style="width:100%;">
                         <tr>
                             <th style="text-align:left">Descrizione</th>
-                            <th style="text-align:right">Imponibile</th>
-                            <th style="text-align:right">Imposta</th>
+                            <th style="text-align:right">Importo</th>
                         </tr>
-                        %for tax_code in tax_codes :
+                        <% tax_code_list = tax_codes(objects[0]) %>
+                        %for tax_code_tuple in tax_code_list :
                         <tr>
-                            <td>${tax_code|entity}
-                            </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['base'])|entity}
-                            </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['amount']) or ''|entity}
+                            <td>${tax_code_tuple[0]|entity}
+                            </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
                             </td>
                         </tr>
                         %endfor
                     </table>
-                </td><td style="padding:10">Totale operazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_operazioni'])|entity}</strong></p><br/></td>
-                <td colspan="2" style="padding:10">Totale imponibili:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_imponibili'])|entity}</strong></p><br/></td>
-            </tr>
-            <tr>
-                <td style="padding:10">Totale variazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_variazioni'])|entity}</strong></p><br/></td>
-                <td style="padding:10">Totale IVA Detraibile:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_iva'])|entity}</strong></p><br/></td>
-                <td style="padding:10">Totale IVA Indetraibile:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_iva_inded'])|entity}</strong></p><br/></td>
+                </td>
             </tr>
         </table>
     </div>

=== modified file 'l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako'
--- l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako	2013-01-08 23:01:16 +0000
+++ l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako	2013-05-02 17:34:30 +0000
@@ -24,11 +24,10 @@
         <tr>
             <th class="left_without_line">Numero</th>
             <th class="left_without_line">Data registrazione</th>
-            <th class="left_without_line">Causale</th>
+            <th class="left_without_line">Sezionale</th>
             <th class="right_without_line">Importo totale</th>
-            <th class="right_without_line">Imponibile</th>
-            <th class="right_without_line">% IVA</th>
             <th class="right_without_line">Imposta</th>
+            <th class="right_without_line">Importo</th>
             <th></th>
         </tr>
         </thead>
@@ -59,7 +58,7 @@
                     </td><td class="left_without_line">
                 %endif
                 %if line['index']==0:
-                    Corrispettivi
+                    ${object.journal_id.name or ''| entity}
                 %endif
                 %if line['index']==0:
                     </td><td class="right_with_line">
@@ -67,25 +66,19 @@
                     </td><td class="right_without_line">
                 %endif
                 %if line['index']==0:
-                    ${ formatLang(line['amount_total']) | entity}
+                    ${ formatLang(object.amount) | entity}
                 %endif
                 </td>
                 %if line['index']==0:
-                    <td class="right_with_line">${ formatLang(line['base'])  or ''| entity}</td>
-                %else:
-                    <td class="right_without_line">${ formatLang(line['base'])  or ''| entity}</td>
-                %endif
-                %if line['index']==0:
-                    <td class="right_with_line">${ line['tax_percentage'] or ''| entity}</td>
-                %else:
-                    <td class="right_without_line">${ line['tax_percentage'] or ''| entity}</td>
-                %endif
-                %if line['index']==0:
-                    <td class="right_with_line">${ formatLang(line['amount'])  or ''| entity}</td>
-                %else:
-                    <td class="right_without_line">${ formatLang(line['amount'])  or ''| entity}</td>
-                %endif
-                <td></td>
+                    <td class="right_with_line">${ (line['tax_code_name'])  or ''| entity}</td>
+                %else:
+                    <td class="right_without_line">${ (line['tax_code_name'])  or ''| entity}</td>
+                %endif
+                %if line['index']==0:
+                    <td class="right_with_line">${ formatLang(line['amount'])| entity}</td>
+                %else:
+                    <td class="right_without_line">${ formatLang(line['amount'])| entity}</td>
+                %endif
                 </tr>
             %endfor
         %endfor
@@ -95,31 +88,25 @@
         <br/>
         <table style="width:100%;  " border="1">
             <tr style="border-style:ridge;border-width:5px">
-                <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>
+                <td colspan="3" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(objects[0].period_id.date_start,date=True)| entity}</strong> al <strong>${formatLang(objects[0].period_id.date_stop,date=True)| entity}</strong></td>
             </tr>
             <tr>
                 <td rowspan="2" style="vertical-align:text-top;padding:10">
                     <table style="width:100%;">
                         <tr>
                             <th style="text-align:left">Descrizione</th>
-                            <th style="text-align:right">Imponibile</th>
-                            <th style="text-align:right">Imposta</th>
+                            <th style="text-align:right">Importo</th>
                         </tr>
-                        %for tax_code in tax_codes :
+                        <% tax_code_list = tax_codes(objects[0]) %>
+                        %for tax_code_tuple in tax_code_list :
                         <tr>
-                            <td>${tax_code|entity}
-                            </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['base'])|entity}
-                            </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['amount']) or ''|entity}
+                            <td>${tax_code_tuple[0]|entity}
+                            </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
                             </td>
                         </tr>
                         %endfor
                     </table>
-                </td><td style="padding:10">Totale operazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_operazioni'])|entity}</strong></p><br/></td>
-                <td style="padding:10">Totale imponibili:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_imponibili'])|entity}</strong></p><br/></td>
-            </tr>
-            <tr>
-                <td style="padding:10">Totale variazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_variazioni'])|entity}</strong></p><br/></td>
-                <td style="padding:10">Totale IVA:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_iva'])|entity}</strong></p><br/></td>
+                </td>
             </tr>
         </table>
     </div>

=== modified file 'l10n_it_vat_registries/templates/registro_iva_vendite.mako'
--- l10n_it_vat_registries/templates/registro_iva_vendite.mako	2013-01-08 23:01:16 +0000
+++ l10n_it_vat_registries/templates/registro_iva_vendite.mako	2013-05-02 17:34:30 +0000
@@ -27,11 +27,10 @@
             <th class="left_without_line">Ragione sociale</th>
             <th class="left_without_line">Numero fattura</th>
             <th class="left_without_line">Data fattura</th>
-            <th class="left_without_line">Causale</th>
+            <th class="left_without_line">Sezionale</th>
             <th class="right_without_line">Totale fattura</th>
-            <th class="right_without_line">Imponibile</th>
-            <th class="right_without_line">% IVA</th>
             <th class="right_without_line">Imposta</th>
+            <th class="right_without_line">Importo</th>
             <th></th>
         </tr>
         </thead>
@@ -78,7 +77,7 @@
                     </td><td class="left_without_line">
                 %endif
                 %if line['index']==0:
-                    ${ formatLang(object.date,date=True) or '' | entity}
+                    ${ formatLang(line['invoice_date'],date=True) or '' | entity}
                 %endif
                 %if line['index']==0:
                     </td><td class="left_with_line">
@@ -86,11 +85,7 @@
                     </td><td class="left_without_line">
                 %endif
                 %if line['index']==0:
-                    %if line['amount_total'] >= 0:
-                        Fattura
-                    %else:
-                        Nota di credito
-                    %endif
+                    ${object.journal_id.name or ''| entity}
                 %endif
                 %if line['index']==0:
                     </td><td class="right_with_line">
@@ -98,25 +93,19 @@
                     </td><td class="right_without_line">
                 %endif
                 %if line['index']==0:
-                    ${ formatLang(line['amount_total']) | entity}
+                    ${ formatLang(object.amount) | entity}
                 %endif
                 </td>
                 %if line['index']==0:
-                    <td class="right_with_line">${ formatLang(line['base'])  or ''| entity}</td>
-                %else:
-                    <td class="right_without_line">${ formatLang(line['base'])  or ''| entity}</td>
-                %endif
-                %if line['index']==0:
-                    <td class="right_with_line">${ line['tax_percentage'] or ''| entity}</td>
-                %else:
-                    <td class="right_without_line">${ line['tax_percentage'] or ''| entity}</td>
-                %endif
-                %if line['index']==0:
-                    <td class="right_with_line">${ formatLang(line['amount'])  or ''| entity}</td>
-                %else:
-                    <td class="right_without_line">${ formatLang(line['amount'])  or ''| entity}</td>
-                %endif
-                <td></td>
+                    <td class="right_with_line">${ (line['tax_code_name'])  or ''| entity}</td>
+                %else:
+                    <td class="right_without_line">${ (line['tax_code_name'])  or ''| entity}</td>
+                %endif
+                %if line['index']==0:
+                    <td class="right_with_line">${ formatLang(line['amount'])| entity}</td>
+                %else:
+                    <td class="right_without_line">${ formatLang(line['amount'])| entity}</td>
+                %endif
                 </tr>
             %endfor
         %endfor
@@ -126,31 +115,25 @@
         <br/>
         <table style="width:100%;  " border="1">
             <tr style="border-style:ridge;border-width:5px">
-                <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>
+                <td colspan="3" style="padding:10; ">Periodo di stampa dal <strong>${formatLang(objects[0].period_id.date_start,date=True)| entity}</strong> al <strong>${formatLang(objects[0].period_id.date_stop,date=True)| entity}</strong></td>
             </tr>
             <tr>
                 <td rowspan="2" style="vertical-align:text-top;padding:10">
                     <table style="width:100%;">
                         <tr>
                             <th style="text-align:left">Descrizione</th>
-                            <th style="text-align:right">Imponibile</th>
-                            <th style="text-align:right">Imposta</th>
+                            <th style="text-align:right">Importo</th>
                         </tr>
-                        %for tax_code in tax_codes :
+                        <% tax_code_list = tax_codes(objects[0]) %>
+                        %for tax_code_tuple in tax_code_list :
                         <tr>
-                            <td>${tax_code|entity}
-                            </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['base'])|entity}
-                            </td><td style="text-align:right">${formatLang(tax_codes[tax_code]['amount']) or ''|entity}
+                            <td>${tax_code_tuple[0]|entity}
+                            </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
                             </td>
                         </tr>
                         %endfor
                     </table>
-                </td><td style="padding:10">Totale operazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_operazioni'])|entity}</strong></p><br/></td>
-                <td style="padding:10">Totale imponibili:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_imponibili'])|entity}</strong></p><br/></td>
-            </tr>
-            <tr>
-                <td style="padding:10">Totale variazioni:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_variazioni'])|entity}</strong></p><br/></td>
-                <td style="padding:10">Totale IVA:<br/><p style="text-align:center"><strong>${formatLang(totali['totale_iva'])|entity}</strong></p><br/></td>
+                </td>
             </tr>
         </table>
     </div>

=== modified file 'l10n_it_vat_registries/wizard/print_registro_iva.py'
--- l10n_it_vat_registries/wizard/print_registro_iva.py	2013-01-29 22:08:50 +0000
+++ l10n_it_vat_registries/wizard/print_registro_iva.py	2013-05-02 17:34:30 +0000
@@ -25,10 +25,14 @@
 
 class wizard_registro_iva(osv.osv_memory):
 
+    def _get_period(self, cr, uid, context=None):
+        ctx = dict(context or {}, account_period_prefer_normal=True)
+        period_ids = self.pool.get('account.period').find(cr, uid, context=ctx)
+        return period_ids[0]
+
     _name = "wizard.registro.iva"
     _columns = {
-        'date_from': fields.date('From date', required=True),
-        'date_to': fields.date('To date', required=True),
+        'period_id': fields.many2one('account.period','Period', required=True),
         'type': fields.selection([
             ('customer', 'Customer Invoices'),
             ('supplier', 'Supplier Invoices'),
@@ -39,65 +43,22 @@
         }
     _defaults = {
         'type': 'customer',
-        'date_from': lambda * a: time.strftime('%Y-%m-%d'),
-        'date_to': lambda * a: time.strftime('%Y-%m-%d'),
-        #'journal_ids': lambda s, cr, uid, c: s.pool.get('account.journal').search(cr, uid, []),
+        'period_id': _get_period,
         }
-        
-    def counterparts_number(self, move_line):
-        counter = 0
-        if  not move_line.credit:
-            for line in move_line.move_id.line_id:
-                if line.credit:
-                    counter += 1
-        elif not move_line.debit:
-            for line in move_line.move_id.line_id:
-                if line.debit:
-                    counter += 1
-        return counter
 
     def print_registro(self, cr, uid, ids, context=None):
-        move_ids = []
-        wizard = self.read(cr, uid, ids)[0]
-        move_line_obj = self.pool.get('account.move.line')
-        tax_pool = self.pool.get('account.tax')
-        search_list = []
-        search_list = [
-            ('journal_id', 'in', wizard['journal_ids']),
-            ('move_id.date', '<=', wizard['date_to']),
-            ('move_id.date', '>=', wizard['date_from']),
-            ('move_id.state', '=', 'posted'),
-            ('tax_code_id', '!=', False),
-            ]
-        move_line_ids = move_line_obj.search(cr, uid, search_list, order='date')
-        if context is None:
-            context = {}
-        for move_line in move_line_obj.browse(cr, uid, move_line_ids):
-            # verifico che sia coinvolto un conto imposta legato ad un'imposta tramite conto standard o conto refund
-            if move_line.tax_code_id.tax_ids or move_line.tax_code_id.ref_tax_ids:
-                if move_line.tax_code_id.tax_ids:
-                    if not tax_pool._have_same_rate(move_line.tax_code_id.tax_ids):
-                        raise osv.except_osv(_('Error'), _('Taxes %s have different rates')
-                            % str(move_line.tax_code_id.tax_ids))
-                if move_line.tax_code_id.ref_tax_ids:
-                    if not tax_pool._have_same_rate(move_line.tax_code_id.ref_tax_ids):
-                        raise osv.except_osv(_('Error'), _('Taxes %s have different rates')
-                            % str(move_line.tax_code_id.ref_tax_ids))
-                # controllo che ogni tax code abbia una e una sola imposta
-                ''' non posso farlo per via dell IVA inclusa nel prezzo
-                if len(move_line.tax_code_id.tax_ids) != 1:
-                    raise osv.except_osv(_('Error'), _('Wrong tax configuration for tax code %s')
-                        % move_line.tax_code_id.name)
-                '''
-                if move_line.move_id.id not in move_ids:
-                    move_ids.append(move_line.move_id.id)
+        wizard = self.browse(cr, uid, ids)[0]
+        move_obj = self.pool.get('account.move')
+        move_ids = move_obj.search(cr, uid, [
+            ('journal_id', 'in', [j.id for j in wizard.journal_ids]),
+            ('period_id', '=', wizard.period_id.id),
+            ('state', '=', 'posted'),
+            ], order='date')
         if not move_ids:
             self.write(cr, uid,  ids, {'message': _('No documents found in the current selection')})
             return True
         datas = {'ids': move_ids}
         datas['model'] = 'account.move'
-        datas['form'] = wizard
-        datas['move_ids'] = move_ids
         res= {
             'type': 'ir.actions.report.xml',
             'datas': datas,
@@ -109,5 +70,3 @@
         elif wizard['type'] == 'corrispettivi':
             res['report_name'] = 'registro_iva_corrispettivi'
         return res
-
-wizard_registro_iva()

=== modified file 'l10n_it_vat_registries/wizard/print_registro_iva.xml'
--- l10n_it_vat_registries/wizard/print_registro_iva.xml	2013-01-08 23:01:16 +0000
+++ l10n_it_vat_registries/wizard/print_registro_iva.xml	2013-05-02 17:34:30 +0000
@@ -8,8 +8,7 @@
             <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Tax Journal">
-                    <field name="date_from"/>
-                    <field name="date_to"/>
+                    <field name="period_id"/>
                     <field name="type" colspan="4"/>
                     <separator string="Journals" colspan="4"/>
                     <field name="journal_ids" colspan="4" nolabel="1" height="250"/>


Follow ups