openobject-italia-core-devs team mailing list archive
-
openobject-italia-core-devs team
-
Mailing list archive
-
Message #01322
lp:~elbati/openobject-italia/6.1-l10n_it_vat_registries_simplified into lp:openobject-italia/6.1
Lorenzo Battistini - Agile BG has proposed merging lp:~elbati/openobject-italia/6.1-l10n_it_vat_registries_simplified into lp:openobject-italia/6.1.
Requested reviews:
OpenERP Italia core devs (openobject-italia-core-devs)
For more details, see:
https://code.launchpad.net/~elbati/openobject-italia/6.1-l10n_it_vat_registries_simplified/+merge/162367
--
https://code.launchpad.net/~elbati/openobject-italia/6.1-l10n_it_vat_registries_simplified/+merge/162367
Your team OpenERP Italia core devs is requested to review the proposed merge of lp:~elbati/openobject-italia/6.1-l10n_it_vat_registries_simplified into lp:openobject-italia/6.1.
=== modified file 'l10n_it_vat_registries/AUTHORS.txt'
--- l10n_it_vat_registries/AUTHORS.txt 2011-07-23 14:39:45 +0000
+++ l10n_it_vat_registries/AUTHORS.txt 2013-05-03 14:50:34 +0000
@@ -1,2 +1,2 @@
-Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxxx>
+Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxx>
Ingrid Barcaro
=== modified file 'l10n_it_vat_registries/__init__.py'
--- l10n_it_vat_registries/__init__.py 2013-01-04 14:02:10 +0000
+++ l10n_it_vat_registries/__init__.py 2013-05-03 14:50:34 +0000
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# Copyright (C) 2011 Associazione OpenERP Italia
+# Copyright (C) 2011-2013 Associazione OpenERP Italia
# (<http://www.openerp-italia.org>).
#
# This program is free software: you can redistribute it and/or modify
@@ -12,7 +12,7 @@
# 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 General Public License for more details.
+# 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/>.
@@ -20,5 +20,5 @@
##############################################################################
import wizard
+import invoice
import account
-import invoice
=== modified file 'l10n_it_vat_registries/__openerp__.py'
--- l10n_it_vat_registries/__openerp__.py 2013-01-04 14:02:10 +0000
+++ l10n_it_vat_registries/__openerp__.py 2013-05-03 14:50:34 +0000
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# Copyright (C) 2011-2012 Associazione OpenERP Italia
+# Copyright (C) 2011-2013 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>)
@@ -14,7 +14,7 @@
# 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 General Public License for more details.
+# 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/>.
@@ -28,13 +28,13 @@
'author': 'OpenERP Italian Community',
'website': 'http://www.openerp-italia.org',
'license': 'AGPL-3',
- "depends" : ['report_webkit', 'l10n_it_account', 'l10n_it_partially_deductible_vat'],
+ "depends" : ['report_webkit', 'l10n_it_base', 'l10n_it_fiscalcode', 'l10n_it_partially_deductible_vat'],
"init_xml" : [
],
"update_xml" : [
'reports.xml',
+ 'wizard/print_registro_iva.xml',
'account_view.xml',
- 'wizard/print_registro_iva.xml',
],
"demo_xml" : [],
"active": False,
=== modified file 'l10n_it_vat_registries/account.py'
--- l10n_it_vat_registries/account.py 2013-01-04 14:02:10 +0000
+++ l10n_it_vat_registries/account.py 2013-05-03 14:50:34 +0000
@@ -1,10 +1,8 @@
# -*- 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>)
+#
+# Copyright (C) 2013 Associazione OpenERP Italia
+# (<http://www.openerp-italia.org>).
#
# 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
@@ -21,28 +19,12 @@
#
##############################################################################
-from osv import fields, osv
-from tools.translate import _
-
-
-class account_tax(osv.osv):
-
- _inherit = 'account.tax'
+from openerp.osv import fields, osv
+from openerp.tools.translate import _
+
+class account_tax_code(osv.osv):
+ _inherit = "account.tax.code"
+
_columns = {
- 'exclude_from_registries': fields.boolean(
- 'Exclude from VAT registries'),
- 'base_tax_ids': fields.one2many(
- 'account.tax', 'base_code_id', 'Base Taxes'), # serve ancora?
+ 'is_base': fields.boolean('Is base', help="This tax code is used for base amounts (field used by VAT registries)"),
}
- _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))
-
=== modified file 'l10n_it_vat_registries/account_view.xml'
--- l10n_it_vat_registries/account_view.xml 2011-08-19 13:08:24 +0000
+++ l10n_it_vat_registries/account_view.xml 2013-05-03 14:50:34 +0000
@@ -1,17 +1,16 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0"?>
<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>
+ <record id="view_tax_code_form" model="ir.ui.view">
+ <field name="name">account.tax.code.form</field>
+ <field name="model">account.tax.code</field>
+ <field name="inherit_id" ref="account.view_tax_code_form"></field>
<field name="arch" type="xml">
- <field name="active" position="after">
- <field name="exclude_from_registries"/>
+ <field name="sign" position="after">
+ <field name="is_base"/>
</field>
</field>
</record>
</data>
</openerp>
+
=== modified file 'l10n_it_vat_registries/invoice.py'
--- l10n_it_vat_registries/invoice.py 2013-01-04 14:02:10 +0000
+++ l10n_it_vat_registries/invoice.py 2013-05-03 14:50:34 +0000
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
-# Copyright (C) 2011 Associazione OpenERP Italia
-# (<http://www.openerp-italia.org>).
+#
+# Copyright (C) 2011-2013 Associazione OpenERP Italia
+# (<http://www.openerp-italia.org>).
#
# 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
@@ -22,323 +22,115 @@
import time
from report import report_sxw
from tools.translate import _
-from decimal import *
-import netsvc
+import logging
+from datetime import datetime
+
+_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
+ self.localcontext['used_tax_codes'][move_line.tax_code_id.id] = True
+ res[move_line.tax_code_id.id] += (move_line.tax_amount
+ * self.localcontext['data']['tax_sign'])
+ 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)
- # calcolo % indetraibile
- actual_tax_amount = base_amount * main_tax.amount
- actual_tax_amount = cur_pool.round(
- self.cr, self.uid, move.company_id.currency_id,
- actual_tax_amount)
- 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
-
- return res
-
- def _get_tax_lines_by_invoice(self, invoice):
+ 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 build_parent_tax_codes(self, tax_code):
+ res={}
+ if tax_code.parent_id and tax_code.parent_id.parent_id:
+ res[tax_code.parent_id.id]=True
+ res.update(self.build_parent_tax_codes(tax_code.parent_id))
+ return res
+
+ def _compute_totals(self, tax_code_ids):
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
-
+ res_dict={}
+ tax_code_obj = self.pool.get('account.tax.code')
+ for period_id in self.localcontext['data']['period_ids']:
+ for tax_code in tax_code_obj.browse(self.cr, self.uid,
+ tax_code_ids, context={
+ 'period_id': period_id,
+ }):
+ if not res_dict.get(tax_code.id):
+ res_dict[tax_code.id] = 0.0
+ res_dict[tax_code.id] += (tax_code.sum_period
+ * self.localcontext['data']['tax_sign'])
+ for tax_code_id in res_dict:
+ tax_code = tax_code_obj.browse(self.cr, self.uid, tax_code_id)
+ if res_dict[tax_code_id]:
+ res.append((tax_code.name,res_dict[tax_code_id],tax_code.is_base))
return res
+
+ def _get_tax_codes(self):
+ return self._compute_totals(self.localcontext['used_tax_codes'].keys())
+
+ def _get_tax_codes_totals(self):
+ parent_codes = {}
+ tax_code_obj = self.pool.get('account.tax.code')
+ for tax_code in tax_code_obj.browse(self.cr, self.uid,
+ self.localcontext['used_tax_codes'].keys()):
+ parent_codes.update(self.build_parent_tax_codes(tax_code))
+ return self._compute_totals(parent_codes.keys())
+
+ def _get_start_date(self):
+ period_obj = self.pool.get('account.period')
+ start_date = False
+ for period in period_obj.browse(self.cr,self.uid,
+ self.localcontext['data']['period_ids']):
+ period_start = datetime.strptime(period.date_start, '%Y-%m-%d')
+ if not start_date or start_date > period_start:
+ start_date = period_start
+ return start_date.strftime('%Y-%m-%d')
+
+ def _get_end_date(self):
+ period_obj = self.pool.get('account.period')
+ end_date = False
+ for period in period_obj.browse(self.cr,self.uid,
+ self.localcontext['data']['period_ids']):
+ period_end = datetime.strptime(period.date_stop, '%Y-%m-%d')
+ if not end_date or end_date < period_end:
+ end_date = period_end
+ return end_date.strftime('%Y-%m-%d')
def __init__(self, cr, uid, name, context):
super(Parser, self).__init__(cr, uid, name, context)
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,
+ 'tax_codes_totals': self._get_tax_codes_totals,
+ 'used_tax_codes': {},
+ 'start_date': self._get_start_date,
+ 'end_date': self._get_end_date,
})
=== modified file 'l10n_it_vat_registries/templates/registro_iva_acquisti.mako'
--- l10n_it_vat_registries/templates/registro_iva_acquisti.mako 2012-08-16 09:25:37 +0000
+++ l10n_it_vat_registries/templates/registro_iva_acquisti.mako 2013-05-03 14:50:34 +0000
@@ -19,7 +19,7 @@
<body>
<h2>Fatture Ricevute</h2>
<% setLang(objects[0].company_id.partner_id.lang or "en_US") %>
- <table style="width:100%;" cellspacing="0">
+ <table style="width:100%; font-size: small;" cellspacing="0">
<thead>
<tr>
<th class="left_without_line">Data registrazione</th>
@@ -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>
@@ -63,7 +61,7 @@
</td><td class="left_without_line">
%endif
%if line['index']==0:
- ${object.partner_id.name or ''| entity}
+ ${object.partner_id.name or ''| entity}
%endif
%if line['index']==0:
</td><td class="left_with_line">
@@ -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
@@ -134,34 +113,87 @@
</table>
<div style="page-break-inside: avoid;">
<br/>
+ <% tax_code_list = tax_codes() %>
+ <% tax_code_totals_list = tax_codes_totals() %>
<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>
- </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>
- </tr>
- %for tax_code in tax_codes :
- <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>
- </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 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>
+ </tr>
+ <tr>
+ <td colspan="2" style="vertical-align:text-top;padding:10">
+ <h3>Dettaglio</h3>
+ <table style="width:100%;">
+ <tr>
+ <th style="text-align:left">Descrizione</th>
+ <th style="text-align:right">Importo</th>
+ </tr>
+ %for tax_code_tuple in tax_code_list :
+ % if not tax_code_tuple[2]:
+ <tr>
+ <td>${tax_code_tuple[0]|entity}
+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
+ </td>
+ </tr>
+ %endif
+ %endfor
+ </table>
+ </td>
+ <td style="vertical-align:text-top;padding:10">
+ <h3>Totali</h3>
+ <table style="width:100%;">
+ <tr>
+ <th style="text-align:left">Descrizione</th>
+ <th style="text-align:right">Importo</th>
+ </tr>
+ %for tax_code_tuple in tax_code_totals_list :
+ % if not tax_code_tuple[2]:
+ <tr>
+ <td>${tax_code_tuple[0]|entity}
+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
+ </td>
+ </tr>
+ %endif
+ %endfor
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" style="vertical-align:text-top;padding:10">
+ <h3>Dettaglio imponibili</h3>
+ <table style="width:100%;">
+ <tr>
+ <th style="text-align:left">Descrizione</th>
+ <th style="text-align:right">Importo</th>
+ </tr>
+ %for tax_code_tuple in tax_code_list :
+ % if tax_code_tuple[2]:
+ <tr>
+ <td>${tax_code_tuple[0]|entity}
+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
+ </td>
+ </tr>
+ %endif
+ %endfor
+ </table>
+ </td>
+ <td style="vertical-align:text-top;padding:10">
+ <h3>Totali imponibili</h3>
+ <table style="width:100%;">
+ <tr>
+ <th style="text-align:left">Descrizione</th>
+ <th style="text-align:right">Importo</th>
+ </tr>
+ %for tax_code_tuple in tax_code_totals_list :
+ % if tax_code_tuple[2]:
+ <tr>
+ <td>${tax_code_tuple[0]|entity}
+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
+ </td>
+ </tr>
+ %endif
+ %endfor
+ </table>
+ </td>
</tr>
</table>
</div>
=== modified file 'l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako'
--- l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako 2012-08-16 09:25:37 +0000
+++ l10n_it_vat_registries/templates/registro_iva_corrispettivi.mako 2013-05-03 14:50:34 +0000
@@ -19,16 +19,15 @@
<body>
<h2>Corrispettivi</h2>
<% setLang(objects[0].company_id.partner_id.lang or "en_US") %>
- <table style="width:100%;" cellspacing="0">
+ <table style="width:100%; font-size: small;" cellspacing="0">
<thead>
<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
@@ -93,33 +86,87 @@
</table>
<div style="page-break-inside: avoid;">
<br/>
+ <% tax_code_list = tax_codes() %>
+ <% tax_code_totals_list = tax_codes_totals() %>
<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>
- </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>
- </tr>
- %for tax_code in tax_codes :
- <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>
- </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 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>
+ </tr>
+ <tr>
+ <td colspan="2" style="vertical-align:text-top;padding:10">
+ <h3>Dettaglio</h3>
+ <table style="width:100%;">
+ <tr>
+ <th style="text-align:left">Descrizione</th>
+ <th style="text-align:right">Importo</th>
+ </tr>
+ %for tax_code_tuple in tax_code_list :
+ % if not tax_code_tuple[2]:
+ <tr>
+ <td>${tax_code_tuple[0]|entity}
+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
+ </td>
+ </tr>
+ %endif
+ %endfor
+ </table>
+ </td>
+ <td style="vertical-align:text-top;padding:10">
+ <h3>Totali</h3>
+ <table style="width:100%;">
+ <tr>
+ <th style="text-align:left">Descrizione</th>
+ <th style="text-align:right">Importo</th>
+ </tr>
+ %for tax_code_tuple in tax_code_totals_list :
+ % if not tax_code_tuple[2]:
+ <tr>
+ <td>${tax_code_tuple[0]|entity}
+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
+ </td>
+ </tr>
+ %endif
+ %endfor
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" style="vertical-align:text-top;padding:10">
+ <h3>Dettaglio imponibili</h3>
+ <table style="width:100%;">
+ <tr>
+ <th style="text-align:left">Descrizione</th>
+ <th style="text-align:right">Importo</th>
+ </tr>
+ %for tax_code_tuple in tax_code_list :
+ % if tax_code_tuple[2]:
+ <tr>
+ <td>${tax_code_tuple[0]|entity}
+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
+ </td>
+ </tr>
+ %endif
+ %endfor
+ </table>
+ </td>
+ <td style="vertical-align:text-top;padding:10">
+ <h3>Totali imponibili</h3>
+ <table style="width:100%;">
+ <tr>
+ <th style="text-align:left">Descrizione</th>
+ <th style="text-align:right">Importo</th>
+ </tr>
+ %for tax_code_tuple in tax_code_totals_list :
+ % if tax_code_tuple[2]:
+ <tr>
+ <td>${tax_code_tuple[0]|entity}
+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
+ </td>
+ </tr>
+ %endif
+ %endfor
+ </table>
+ </td>
</tr>
</table>
</div>
=== modified file 'l10n_it_vat_registries/templates/registro_iva_vendite.mako'
--- l10n_it_vat_registries/templates/registro_iva_vendite.mako 2012-08-16 09:25:37 +0000
+++ l10n_it_vat_registries/templates/registro_iva_vendite.mako 2013-05-03 14:50:34 +0000
@@ -19,7 +19,7 @@
<body>
<h2>Fatture Emesse</h2>
<% setLang(objects[0].company_id.partner_id.lang or "en_US") %>
- <table style="width:100%;" cellspacing="0">
+ <table style="width:100%; font-size: small;" cellspacing="0">
<thead>
<tr>
<th class="left_without_line">Data registrazione</th>
@@ -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
@@ -124,33 +113,87 @@
</table>
<div style="page-break-inside: avoid;">
<br/>
+ <% tax_code_list = tax_codes() %>
+ <% tax_code_totals_list = tax_codes_totals() %>
<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>
- </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>
- </tr>
- %for tax_code in tax_codes :
- <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>
- </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 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>
+ </tr>
+ <tr>
+ <td colspan="2" style="vertical-align:text-top;padding:10">
+ <h3>Dettaglio</h3>
+ <table style="width:100%;">
+ <tr>
+ <th style="text-align:left">Descrizione</th>
+ <th style="text-align:right">Importo</th>
+ </tr>
+ %for tax_code_tuple in tax_code_list :
+ % if not tax_code_tuple[2]:
+ <tr>
+ <td>${tax_code_tuple[0]|entity}
+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
+ </td>
+ </tr>
+ %endif
+ %endfor
+ </table>
+ </td>
+ <td style="vertical-align:text-top;padding:10">
+ <h3>Totali</h3>
+ <table style="width:100%;">
+ <tr>
+ <th style="text-align:left">Descrizione</th>
+ <th style="text-align:right">Importo</th>
+ </tr>
+ %for tax_code_tuple in tax_code_totals_list :
+ % if not tax_code_tuple[2]:
+ <tr>
+ <td>${tax_code_tuple[0]|entity}
+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
+ </td>
+ </tr>
+ %endif
+ %endfor
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" style="vertical-align:text-top;padding:10">
+ <h3>Dettaglio imponibili</h3>
+ <table style="width:100%;">
+ <tr>
+ <th style="text-align:left">Descrizione</th>
+ <th style="text-align:right">Importo</th>
+ </tr>
+ %for tax_code_tuple in tax_code_list :
+ % if tax_code_tuple[2]:
+ <tr>
+ <td>${tax_code_tuple[0]|entity}
+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
+ </td>
+ </tr>
+ %endif
+ %endfor
+ </table>
+ </td>
+ <td style="vertical-align:text-top;padding:10">
+ <h3>Totali imponibili</h3>
+ <table style="width:100%;">
+ <tr>
+ <th style="text-align:left">Descrizione</th>
+ <th style="text-align:right">Importo</th>
+ </tr>
+ %for tax_code_tuple in tax_code_totals_list :
+ % if tax_code_tuple[2]:
+ <tr>
+ <td>${tax_code_tuple[0]|entity}
+ </td><td style="text-align:right">${formatLang(tax_code_tuple[1])|entity}
+ </td>
+ </tr>
+ %endif
+ %endfor
+ </table>
+ </td>
</tr>
</table>
</div>
=== modified file 'l10n_it_vat_registries/wizard/__init__.py'
--- l10n_it_vat_registries/wizard/__init__.py 2013-01-04 14:02:10 +0000
+++ l10n_it_vat_registries/wizard/__init__.py 2013-05-03 14:50:34 +0000
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# Copyright (C) 2011 Associazione OpenERP Italia
+# Copyright (C) 2011-2013 Associazione OpenERP Italia
# (<http://www.openerp-italia.org>).
#
# This program is free software: you can redistribute it and/or modify
@@ -12,7 +12,7 @@
# 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 General Public License for more details.
+# 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/>.
=== modified file 'l10n_it_vat_registries/wizard/print_registro_iva.py'
--- l10n_it_vat_registries/wizard/print_registro_iva.py 2013-01-04 14:02:10 +0000
+++ l10n_it_vat_registries/wizard/print_registro_iva.py 2013-05-03 14:50:34 +0000
@@ -25,79 +25,61 @@
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
+
_name = "wizard.registro.iva"
_columns = {
- 'date_from': fields.date('From date', required=True),
- 'date_to': fields.date('To date', required=True),
+ '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),
'type': fields.selection([
('customer', 'Customer Invoices'),
('supplier', 'Supplier Invoices'),
('corrispettivi', 'Corrispettivi'),
], 'Layout', required=True),
'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),
+ 'tax_sign': fields.float('Tax amount sign',
+ help="Use -1 you have negative tax amounts and you want to print them prositive"),
'message': fields.char('Message', size=64, readonly=True),
}
_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_ids': _get_period,
+ 'tax_sign': 1.0,
}
-
- 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')
+ obj_model_data = self.pool.get('ir.model.data')
+ move_ids = move_obj.search(cr, uid, [
+ ('journal_id', 'in', [j.id for j in wizard.journal_ids]),
+ ('period_id', 'in', [p.id for p in wizard.period_ids]),
+ ('state', '=', 'posted'),
+ ], order='date')
if not move_ids:
self.write(cr, uid, ids, {'message': _('No documents found in the current selection')})
- return True
+ model_data_ids = obj_model_data.search(cr, uid, [('model','=','ir.ui.view'), ('name','=','wizard_registro_iva')])
+ resource_id = obj_model_data.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id']
+ return {
+ 'name': _('No documents'),
+ 'res_id': ids[0],
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'wizard.registro.iva',
+ 'views': [(resource_id,'form')],
+ 'context': context,
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ }
datas = {'ids': move_ids}
datas['model'] = 'account.move'
- datas['form'] = wizard
- datas['move_ids'] = move_ids
+ datas['period_ids'] = [p.id for p in wizard.period_ids]
+ datas['layout'] = wizard['type']
+ datas['tax_sign'] = wizard['tax_sign']
res= {
'type': 'ir.actions.report.xml',
'datas': datas,
@@ -109,5 +91,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 2011-08-06 10:23:30 +0000
+++ l10n_it_vat_registries/wizard/print_registro_iva.xml 2013-05-03 14:50:34 +0000
@@ -8,9 +8,10 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Tax Journal">
- <field name="date_from"/>
- <field name="date_to"/>
- <field name="type" colspan="4"/>
+ <field name="type" />
+ <field name="tax_sign"/>
+ <separator string="Periods" colspan="4"/>
+ <field name="period_ids" colspan="4" nolabel="1" height="250"/>
<separator string="Journals" colspan="4"/>
<field name="journal_ids" colspan="4" nolabel="1" height="250"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
Follow ups