← Back to team overview

avanzosc team mailing list archive

[Merge] lp:~avanzosc-security-team/avanzosc/dos_vat_clearance_report into lp:~avanzosc-security-team/avanzosc/72horas

 

Oihane (Avanzosc) has proposed merging lp:~avanzosc-security-team/avanzosc/dos_vat_clearance_report into lp:~avanzosc-security-team/avanzosc/72horas.

Requested reviews:
  Pedro Manuel Baeza (pedro.baeza)

For more details, see:
https://code.launchpad.net/~avanzosc-security-team/avanzosc/dos_vat_clearance_report/+merge/226070

Estaba sin subir pero migrado por Mikel
-- 
https://code.launchpad.net/~avanzosc-security-team/avanzosc/dos_vat_clearance_report/+merge/226070
Your team Avanzosc_security is subscribed to branch lp:~avanzosc-security-team/avanzosc/72horas.
=== modified file 'dos_vat_clearance_report/__init__.py'
--- dos_vat_clearance_report/__init__.py	2014-06-11 10:23:47 +0000
+++ dos_vat_clearance_report/__init__.py	2014-07-09 07:36:58 +0000
@@ -21,6 +21,6 @@
 #
 ##############################################################################
 
-import account_tax_code
-import report
-import wizard
+from . import models
+from . import report
+from . import wizard

=== modified file 'dos_vat_clearance_report/__openerp__.py'
--- dos_vat_clearance_report/__openerp__.py	2014-06-11 10:23:47 +0000
+++ dos_vat_clearance_report/__openerp__.py	2014-07-09 07:36:58 +0000
@@ -21,26 +21,25 @@
 #
 ##############################################################################
 {
-	"name" : "VAT Clearance Report",
-	"version" : "1.0",
-	"author" : "DOS",
-	"website" : "www.dos-sl.es",
-    "license" : "GPL-3",
-	"depends" : ["account"],
-	"category" : "Accounting",
-	"description": """
-Add some common financial/accounting reports and some wizards to quickly compute them:
+    "name": "VAT Clearance Report",
+    "version": "1.0",
+    "author": "DOS",
+    "website": "www.dos-sl.es",
+    "license": "GPL-3",
+    "depends": ["account"],
+    "category": "Accounting",
+    "description": """
+Add some common financial/accounting reports """
+    """and some wizards to quickly compute them:
   * VAT clearance
 
-They can be found in the "Financial Management/Legal Statements/Generic Reports" menu.
+They can be found in the "Financial Management/Legal"""
+    """ Statements/Generic Reports" menu.
 """,
-	"init_xml" : [],
-	"demo_xml" : [],
-	"update_xml" : [
-		"account_tax_code_view.xml",
-		"account_report_report.xml",
-		"account_report_wizard.xml",
-	],
-	"active": False,
-	"installable": True
+    "data": [
+        "views/account_tax_code_view.xml",
+        "report/account_report_report.xml",
+        "wizard/account_report_wizard.xml",
+    ],
+    "installable": True
 }

=== added directory 'dos_vat_clearance_report/models'
=== added file 'dos_vat_clearance_report/models/__init__.py'
--- dos_vat_clearance_report/models/__init__.py	1970-01-01 00:00:00 +0000
+++ dos_vat_clearance_report/models/__init__.py	2014-07-09 07:36:58 +0000
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2012 DOS (http://www.dos-sl.es) All Rights Reserved.
+#
+#    $Id$
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU 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 General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from . import account_tax_code
\ No newline at end of file

=== renamed file 'dos_vat_clearance_report/account_tax_code.py' => 'dos_vat_clearance_report/models/account_tax_code.py'
--- dos_vat_clearance_report/account_tax_code.py	2014-06-11 10:23:47 +0000
+++ dos_vat_clearance_report/models/account_tax_code.py	2014-07-09 07:36:58 +0000
@@ -21,23 +21,16 @@
 #
 ##############################################################################
 
-from osv import fields,osv
-
-class account_tax_code(osv.osv):
-
-	_inherit = 'account.tax.code'
-	
-	_columns = {
-		'irpf' : fields.boolean('IRPF', help="Check this box if tax code is IRPF"),
-	}
-	
-	_defaults = {
-		'irpf': False,
-	}
-
-account_tax_code()
-
-
-
-
-
+from openerp.osv import fields, orm
+
+
+class AccountTaxCode(orm.Model):
+
+    _inherit = 'account.tax.code'
+    _columns = {
+        'irpf': fields.boolean('IRPF',
+                               help="Check this box if tax code is IRPF"),
+    }
+    _defaults = {
+        'irpf': False,
+    }

=== modified file 'dos_vat_clearance_report/report/__init__.py'
--- dos_vat_clearance_report/report/__init__.py	2014-06-11 10:23:47 +0000
+++ dos_vat_clearance_report/report/__init__.py	2014-07-09 07:36:58 +0000
@@ -21,5 +21,5 @@
 #
 ##############################################################################
 
-import vat_clearance_list
+from . import vat_clearance_list
 

=== renamed file 'dos_vat_clearance_report/account_report_report.xml' => 'dos_vat_clearance_report/report/account_report_report.xml'
=== modified file 'dos_vat_clearance_report/report/rml_parse.py'
--- dos_vat_clearance_report/report/rml_parse.py	2014-06-11 10:23:47 +0000
+++ dos_vat_clearance_report/report/rml_parse.py	2014-07-09 07:36:58 +0000
@@ -21,66 +21,68 @@
 #
 ##############################################################################
 
-from report import report_sxw
+from openerp.report import report_sxw
 import xml.dom.minidom
-import os, time
-import osv
+import os
+import time
 import re
-import tools
-import pooler
 import re
 import sys
 
 
-class rml_parse(report_sxw.rml_parse):
+class RmlParse(report_sxw.rml_parse):
 
     def __init__(self, cr, uid, name, context):
-        super(rml_parse, self).__init__(cr, uid, name, context=None)
+        super(RmlParse, self).__init__(cr, uid, name, context=None)
         self.localcontext.update({
             'comma_me': self.comma_me,
             'format_date': self._get_and_change_date_format_for_swiss,
-            'strip_name' : self._strip_name,
-            'explode_name' : self._explode_name,
+            'strip_name': self._strip_name,
+            'explode_name': self._explode_name,
         })
 
-    def comma_me(self,amount):
+    def comma_me(self, amount):
         if not amount:
             amount = 0.0
-        if  type(amount) is float :
-            amount = str('%.2f'%amount)
-        else :
+        if type(amount) is float:
+            amount = str('%.2f' % amount)
+        else:
             amount = str(amount)
         if (amount == '0'):
-             return ' '
+            return ' '
         orig = amount
         new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount)
         if orig == new:
             return new
         else:
             return self.comma_me(new)
-    def _ellipsis(self, string, maxlen=100, ellipsis = '...'):
+
+    def _ellipsis(self, string, maxlen=100, ellipsis='...'):
         ellipsis = ellipsis or ''
         try:
-            return string[:maxlen - len(ellipsis) ] + (ellipsis, '')[len(string) < maxlen]
+            return string[
+                :maxlen - len(ellipsis)] + (ellipsis, '')[len(string) < maxlen]
         except Exception, e:
             return False
+
     def _strip_name(self, name, maxlen=50):
         return self._ellipsis(name, maxlen, '...')
-            
-    def _get_and_change_date_format_for_swiss (self,date_to_format):
-        date_formatted=''
+
+    def _get_and_change_date_format_for_swiss(self, date_to_format):
+        date_formatted = ''
         if date_to_format:
-            date_formatted = strptime(date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y')
+            date_formatted = (
+                strptime(date_to_format, '%Y-%m-%d').strftime('%d.%m.%Y'))
         return date_formatted
-    
-    def _explode_name(self,chaine,length):
+
+    def _explode_name(self, chaine, length):
         # We will test if the size is less then account
         full_string = ''
         if (len(str(chaine)) <= length):
             return chaine
         #
         else:
-            chaine = unicode(chaine,'utf8').encode('iso-8859-1')
+            chaine = unicode(chaine, 'utf8').encode('iso-8859-1')
             rup = 0
             for carac in chaine:
                 rup = rup + 1
@@ -90,10 +92,9 @@
                     rup = 0
                 else:
                     full_string = full_string + carac
-            
         return full_string
-    
-    def makeAscii(self,str):
+
+    def makeAscii(self, str):
         try:
             Stringer = str.encode("utf-8")
         except UnicodeDecodeError:
@@ -106,17 +107,19 @@
         else:
             return Stringer
         return Stringer
-    def explode_this(self,chaine,length):
-        #chaine = self.repair_string(chaine)
+
+    def explode_this(self, chaine, length):
+        # chaine = self.repair_string(chaine)
         chaine = rstrip(chaine)
         ast = list(chaine)
         i = length
         while i <= len(ast):
-            ast.insert(i,'\n')
+            ast.insert(i, '\n')
             i = i + length
         chaine = str("".join(ast))
         return chaine
-    def repair_string(self,chaine):
+
+    def repair_string(self, chaine):
         ast = list(chaine)
         UnicodeAst = []
         _previouslyfound = False
@@ -129,28 +132,25 @@
                 to_reencode = elem + ast[i+1]
                 Good_char = to_reencode.decode('utf-8')
                 UnicodeAst.append(Good_char)
-                i += i +2
+                i += i + 2
             else:
                 UnicodeAst.append(elem)
                 i += i + 1
-            
-        
         return "".join(UnicodeAst)
-        
-    def ReencodeAscii(self,str):
+
+    def ReencodeAscii(self, str):
         try:
             Stringer = str.decode("ascii")
         except UnicodeEncodeError:
             return str.encode("ascii")
         except UnicodeDecodeError:
             return str.encode("ascii")
-        
         else:
             return Stringer
 
-
     # def _add_header(self, node):
-    #     rml_head = tools.file_open('specific_param/report/header/corporate_rml_header_ch.rml').read()
+    #     rml_head = tools.file_open(
+    #        'specific_param/report/header/corporate_rml_header_ch.rml').read()
     #     head_dom = xml.dom.minidom.parseString(rml_head)
     #     #for frame in head_dom.getElementsByTagName('frame'):
     #     #    frame.parentNode.removeChild(frame)
@@ -160,13 +160,11 @@
     #             found = self._find_node(node, tag.localName)
     #     #        rml_frames = found.getElementsByTagName('frame')
     #             if found:
-    #                 if tag.hasAttribute('position') and (tag.getAttribute('position')=='inside'):
+    #                 if (tag.hasAttribute('position') and
+    #                         (tag.getAttribute('position')=='inside')):
     #                     found.appendChild(tag)
     #                 else:
     #                     found.parentNode.replaceChild(tag, found)
     #     #        for frame in rml_frames:
     #     #            tag.appendChild(frame)
     #    return True
-
-
-

=== modified file 'dos_vat_clearance_report/report/vat_clearance_list.py'
--- dos_vat_clearance_report/report/vat_clearance_list.py	2014-06-11 10:23:47 +0000
+++ dos_vat_clearance_report/report/vat_clearance_list.py	2014-07-09 07:36:58 +0000
@@ -29,274 +29,298 @@
 import pooler
 from tools.translate import _
 
-class print_vat_clearance_list(rml_parse.rml_parse):
-	""" Report that print invoices grouped by currency and type """
-	_name = 'report.account.print_vat_clearance_list'
-
-
-	def __init__(self, cr, uid, name, context):
-		super(print_vat_clearance_list, self).__init__(cr, uid, name, context)
-		#contain tuples of in invoices : (curreny, [browse records], currency_untaxed, currency_tax, currency_total)
-		self.in_invoices = []
-
-		#contain tuples of out invoices : (curreny, [browse records], currency_untaxed, currency_tax, currency_total)
-		self.out_invoices = []
-
-		#contain difference
-		self.differences = []
-		
-		self.localcontext.update({
-			'time': time,
-			'in_invoices': self.in_invoices,
-			'out_invoices': self.out_invoices,
-			'differences': self.differences,
-			'vat_taxes': False,
-			'irpf_taxes': False,
-			'report_name': '',
-		})
-
-
-	def set_context(self, objects, data, ids, report_type = None):
-		"""We do the grouping and proccessing of invoices"""
-		invoice_obj = self.pool.get('account.invoice')
-
-		if data['model'] == 'ir.ui.menu':
-			invoice_types = []
-			if data['form']['out_invoice']:
-				invoice_types.append('out_invoice')
-			if data['form']['out_refund']:
-				invoice_types.append('out_refund')
-			if data['form']['in_invoice']:
-				invoice_types.append('in_invoice')
-			if data['form']['in_refund']:
-				invoice_types.append('in_refund')
-			invoice_states = []
-			if data['form']['draft']:
-				invoice_states.append('draft')
-			if data['form']['proforma']:
-				invoice_states.append('proforma')
-				invoice_states.append('proforma2')
-			if data['form']['open']:
-				invoice_states.append('open')
-			if data['form']['paid']:
-				invoice_states.append('paid')
-			if data['form']['cancel']:
-				invoice_states.append('cancel')
-			where = [('company_id','=',data['form']['company_id']),('type','in',invoice_types),('state','in',invoice_states)]
-			if data['form']['state'] in ['byperiod','all']:
-				period_ids = data['form']['periods'][0][2]
-				periods = ','.join([str(id) for id in period_ids])
-				where.append(('period_id','in',period_ids))
-			if data['form']['state'] in ['bydate','all','none']:
-				where.append(('date_invoice','>=',data['form']['date_from']))
-				where.append(('date_invoice','<=',data['form']['date_to']))
-			#print where
-			ids = invoice_obj.search(self.cr, self.uid, where)
-			objects = invoice_obj.browse(self.cr, self.uid, ids)
-
-			self.localcontext.update({
-				'vat_taxes': data['form'].get('vat_taxes'),
-				'irpf_taxes': data['form'].get('irpf_taxes'),
-				'report_name': data['form'].get('report_name'),
-			})
-		
-		vat_taxes = data['form'].get('vat_taxes') or False    
-		irpf_taxes = data['form'].get('irpf_taxes') or False
-
-		if not ids :
-			return super(print_vat_clearance_list, self).set_context(objects, data, ids, report_type)
-		
-		if not isinstance(ids, list) :
-			ids = [ids]
-		# we create temp list that will be used for store invoices by type
-		ininv = []
-		outinv = []
-
-		# we get the invoices and sort them by types
-		invoices = invoice_obj.browse(self.cr, self.uid, ids)
-		for inv in invoices :
-			if inv.type in ('in_invoice', 'in_refund'):
-				ininv.append(inv)
-			if inv.type in ('out_invoice', 'out_refund'):
-				outinv.append(inv)
-
-		# we process the invoice and attribute them to the property
-		self.filter_invoices(outinv, self.out_invoices, vat_taxes, irpf_taxes)
-		self.filter_invoices(ininv, self.in_invoices, vat_taxes, irpf_taxes)
-		if not irpf_taxes:
-			self.calculate_differences(self.differences, self.in_invoices, self.out_invoices)
-		super(print_vat_clearance_list, self).set_context(objects, data, ids, report_type)
-
-
-	def filter_invoices(self, list, dest, vat_taxes=False, irpf_taxes=False):
-		if not list :
-			return 
-		tmp = {}
-
-		#
-		# Group by currency
-		#
-		for inv in list:
-			currency = inv.currency_id.name
-			if tmp.has_key(currency) :
-				tmp[currency].append(inv)
-			else :
-				tmp[currency] = [inv]
-
-				
-		#
-		# Compute the total for each currency group
-		#
-		for curr in tmp:
-			base = amount = total = 0
-			dic_tax_lines = {}
-			tax_lines = []
-			
-			if vat_taxes or irpf_taxes:
-				
-				for tmpinv in tmp[curr]:
-	
-					inv_factor = tmpinv.type in ('out_refund', 'in_refund') and -1 or 1
-					
-					for tax_line in tmpinv.tax_line:
-						
-						if (tax_line.tax_code_id and ((tax_line.tax_code_id.irpf == irpf_taxes) or (not tax_line.tax_code_id.irpf == vat_taxes))) or not tax_line.tax_code_id:
-							
-							cur = tmpinv.currency_id
-							tax_base = self.pool.get('res.currency').round(self.cr, self.uid, cur, tax_line.base)
-							tax_amount = self.pool.get('res.currency').round(self.cr, self.uid, cur, tax_line.amount)
-							
-							#Caso especial en caso de impuestos intracomunitarios
-							if tax_line.tax_code_id and tax_line.base_code_id.code and (tax_line.base_code_id.code in ('[19]') or tax_line.tax_code_id.code in ('[20]')):
-								
-								added = False
-								
-								for line in self.out_invoices:
-					
-									if line[0] == curr:
-										for taxes in line[1]:
-											if tax_line.name == taxes['name']:
-												
-												
-												taxes['base'] = taxes['base'] + (tax_base * inv_factor)
-												taxes['amount'] = taxes['amount'] - (tax_amount * inv_factor)
-												taxes['total'] = taxes['total'] + ((tax_base * inv_factor) - (tax_amount * inv_factor))
-												line[2] = line[2] + (tax_base * inv_factor)
-												line[3] = line[3] - (tax_amount * inv_factor)
-												line[4] = line[4] + ((tax_base * inv_factor) - (tax_amount * inv_factor))
-												added = True
-												break
-												
-										if not added:
-											line[1].append({
-													'name': tax_line.name,
-													'base': (tax_base * inv_factor),
-													'amount': -(tax_amount * inv_factor),
-													'total': (tax_base * inv_factor) - (tax_amount * inv_factor)
-												   })
-											line[2] = line[2] + (tax_base * inv_factor)
-											line[3] = line[3] - (tax_amount * inv_factor)
-											line[4] = line[4] + ((tax_base * inv_factor) - (tax_amount * inv_factor))
-											added = True
-										break
-									
-								if not added:
-									self.out_invoices.append([curr, [{
-													'name': tax_line.name,
-													'base': (tax_base * inv_factor),
-													'amount': -(tax_amount * inv_factor),
-													'total': (tax_base * inv_factor) - (tax_amount * inv_factor)                                                        
-											}], (tax_base * inv_factor), -(tax_amount * inv_factor), ((tax_base * inv_factor) - (tax_amount * inv_factor))])
-									
-								continue
-							
-							#Caso normal
-							if tax_line.name in dic_tax_lines:
-								dic_tax_lines.update({
-									tax_line.name: {
-													'name': tax_line.name,
-													'base': dic_tax_lines[tax_line.name]['base'] + (tax_base * inv_factor),
-													'amount': dic_tax_lines[tax_line.name]['amount'] + (tax_amount * inv_factor),
-													'total': dic_tax_lines[tax_line.name]['total'] + ((tax_base * inv_factor) + (tax_amount * inv_factor))
-												   }                                                         
-								})
-							else:
-								dic_tax_lines.update({
-									tax_line.name: {
-													'name': tax_line.name,
-													'base': (tax_base * inv_factor),
-													'amount': (tax_amount * inv_factor),
-													'total': (tax_base * inv_factor) + (tax_amount * inv_factor)
-												   }                                                         
-								})
-								
-							base += (tax_base * inv_factor)
-							amount += (tax_amount * inv_factor)
-							total += (tax_base * inv_factor) + (tax_amount * inv_factor)
-							
-				for tax in dic_tax_lines:
-					tax_lines.append(dic_tax_lines[tax])
-		   
-			# Append the tuple to the property
-			dest.append([curr, tax_lines, base, amount, total])
-		del tmp
-		
-		
-	def calculate_differences(self, dest, in_invoices, out_invoices):
-		
-		dic_lines = {}
-		
-		#
-		# Compute the total for each currency group
-		#     
-		for line_out in out_invoices:
-			if line_out[0] in dic_lines:
-				dic_lines.update({
-					line_out[0]: {
-									'currency': line_out[0],
-									'base': dic_lines[line_out[0]]['base'] + line_out[2],
-									'amount': dic_lines[line_out[0]]['amount'] + line_out[3],
-									'total': dic_lines[line_out[0]]['total'] + line_out[4],
-									'text': (dic_lines[line_out[0]]['amount'] + line_out[3]) >= 0 and _('TO ENTERED') or _('TO RETURNED'),
-								   }                                                         
-				})
-			else:
-				dic_lines.update({
-					line_out[0]: {
-									'currency': line_out[0],
-									'base': line_out[2],
-									'amount': line_out[3],
-									'total': line_out[4],
-									'text': line_out[3] >= 0 and _('TO ENTERED') or _('TO RETURNED'),
-								   }                                                         
-				})
-				
-		for line_in in in_invoices:
-			if line_in[0] in dic_lines:
-				dic_lines.update({
-					line_in[0]: {
-									'currency': line_in[0],
-									'base': dic_lines[line_in[0]]['base'] - line_in[2],
-									'amount': dic_lines[line_in[0]]['amount'] - line_in[3],
-									'total': dic_lines[line_in[0]]['total'] - line_in[4],
-									'text': (dic_lines[line_in[0]]['amount'] - line_in[3]) >= 0 and _('TO ENTERED') or _('TO RETURNED'),
-								   }                                                         
-				})
-			else:
-				dic_lines.update({
-					line_in[0]: {
-									'currency': line_in[0],
-									'base': -line_in[2],
-									'amount': -line_in[3],
-									'total': -line_in[4],
-									'text': -line_in[3] >= 0 and _('TO ENTERED') or _('TO RETURNED'),
-								   }                                                     
-				})
-			
-		#Return total difference
-		for line in dic_lines:
-			# Append the tuple to the property
-			dest.append(dic_lines[line])
-
-
-report_sxw.report_sxw('report.account.vat.clearance.list.report', 'account.invoice', 'addons/dos_vat_clearance_report/report/vat_clearance_list.rml', parser=print_vat_clearance_list, header=False)
+
+class PrintVatClearanceList(rml_parse.rml_parse):
+    """ Report that print invoices grouped by currency and type """
+    _name = 'report.account.print_vat_clearance_list'
+
+    def __init__(self, cr, uid, name, context):
+        super(PrintVatClearanceList, self).__init__(cr, uid, name, context)
+        # contain tuples of in invoices :
+        # (curreny, [browse records],
+        #  currency_untaxed, currency_tax, currency_total)
+        self.in_invoices = []
+        # contain tuples of out invoices :
+        # (curreny, [browse records],currency_untaxed,
+        #  currency_tax, currency_total)
+        self.out_invoices = []
+        # contain difference
+        self.differences = []
+        self.localcontext.update({
+            'time': time,
+            'in_invoices': self.in_invoices,
+            'out_invoices': self.out_invoices,
+            'differences': self.differences,
+            'vat_taxes': False,
+            'irpf_taxes': False,
+            'report_name': '',
+        })
+
+    def set_context(self, objects, data, ids, report_type=None):
+        """We do the grouping and proccessing of invoices"""
+        invoice_obj = self.pool['account.invoice']
+        if data['model'] == 'ir.ui.menu':
+            invoice_types = []
+            if data['form']['out_invoice']:
+                invoice_types.append('out_invoice')
+            if data['form']['out_refund']:
+                invoice_types.append('out_refund')
+            if data['form']['in_invoice']:
+                invoice_types.append('in_invoice')
+            if data['form']['in_refund']:
+                invoice_types.append('in_refund')
+            invoice_states = []
+            if data['form']['draft']:
+                invoice_states.append('draft')
+            if data['form']['proforma']:
+                invoice_states.append('proforma')
+                invoice_states.append('proforma2')
+            if data['form']['open']:
+                invoice_states.append('open')
+            if data['form']['paid']:
+                invoice_states.append('paid')
+            if data['form']['cancel']:
+                invoice_states.append('cancel')
+            where = [('company_id', '=', data['form']['company_id']),
+                     ('type', 'in', invoice_types),
+                     ('state', 'in', invoice_states)]
+            if data['form']['state'] in ['byperiod', 'all']:
+                period_ids = data['form']['periods'][0][2]
+                periods = ','.join([str(id) for id in period_ids])
+                where.append(('period_id', 'in', period_ids))
+            if data['form']['state'] in ['bydate', 'all', 'none']:
+                where.append(('date_invoice', '>=', data['form']['date_from']))
+                where.append(('date_invoice', '<=', data['form']['date_to']))
+            # print where
+            ids = invoice_obj.search(self.cr, self.uid, where)
+            objects = invoice_obj.browse(self.cr, self.uid, ids)
+            self.localcontext.update({
+                'vat_taxes': data['form'].get('vat_taxes'),
+                'irpf_taxes': data['form'].get('irpf_taxes'),
+                'report_name': data['form'].get('report_name'),
+            })
+        vat_taxes = data['form'].get('vat_taxes') or False
+        irpf_taxes = data['form'].get('irpf_taxes') or False
+        if not ids:
+            return super(
+                PrintVatClearanceList, self).set_context(objects, data,
+                                                         ids, report_type)
+        if not isinstance(ids, list):
+            ids = [ids]
+        # we create temp list that will be used for store invoices by type
+        ininv = []
+        outinv = []
+        # we get the invoices and sort them by types
+        invoices = invoice_obj.browse(self.cr, self.uid, ids)
+        for inv in invoices:
+            if inv.type in ('in_invoice', 'in_refund'):
+                ininv.append(inv)
+            if inv.type in ('out_invoice', 'out_refund'):
+                outinv.append(inv)
+        # we process the invoice and attribute them to the property
+        self.filter_invoices(outinv, self.out_invoices, vat_taxes, irpf_taxes)
+        self.filter_invoices(ininv, self.in_invoices, vat_taxes, irpf_taxes)
+        if not irpf_taxes:
+            self.calculate_differences(self.differences,
+                                       self.in_invoices, self.out_invoices)
+        super(PrintVatClearanceList, self).set_context(objects, data, ids,
+                                                       report_type)
+
+    def filter_invoices(self, list, dest, vat_taxes=False, irpf_taxes=False):
+        if not list:
+            return
+        tmp = {}
+
+        #
+        # Group by currency
+        #
+        for inv in list:
+            currency = inv.currency_id.name
+            if currency in tmp:
+                tmp[currency].append(inv)
+            else:
+                tmp[currency] = [inv]
+        #
+        # Compute the total for each currency group
+        #
+        for curr in tmp:
+            base = amount = total = 0
+            dic_tax_lines = {}
+            tax_lines = []
+            if vat_taxes or irpf_taxes:
+                for tmpinv in tmp[curr]:
+                    inv_factor = (tmpinv.type in ('out_refund', 'in_refund')
+                                  and -1 or 1)
+                    for tax_line in tmpinv.tax_line:
+                        if ((tax_line.tax_code_id and
+                                ((tax_line.tax_code_id.irpf == irpf_taxes) or
+                                 (not tax_line.tax_code_id.irpf == vat_taxes)))
+                                or not tax_line.tax_code_id):
+                            cur = tmpinv.currency_id
+                            tax_base = self.pool['res.currency'].round(
+                                self.cr, self.uid, cur, tax_line.base)
+                            tax_amount = self.pool['res.currency'].round(
+                                self.cr, self.uid, cur, tax_line.amount)
+                            # Caso especial en caso de
+                            # impuestos intracomunitarios
+                            if (tax_line.tax_code_id and
+                                    tax_line.base_code_id.code and
+                                    (tax_line.base_code_id.code in ('[19]') or
+                                     tax_line.tax_code_id.code in ('[20]'))):
+                                added = False
+                                for line in self.out_invoices:
+                                    if line[0] == curr:
+                                        for taxes in line[1]:
+                                            if tax_line.name == taxes['name']:
+                                                taxes['base'] = (
+                                                    taxes['base'] + (tax_base *
+                                                                     inv_factor
+                                                                     ))
+                                                taxes['amount'] = (
+                                                    taxes['amount'] -
+                                                    (tax_amount * inv_factor))
+                                                taxes['total'] = (
+                                                    taxes['total'] +
+                                                    ((tax_base * inv_factor) -
+                                                     (tax_amount * inv_factor)
+                                                     ))
+                                                line[2] += (tax_base *
+                                                            inv_factor)
+                                                line[3] -= (tax_amount *
+                                                            inv_factor)
+                                                line[4] += ((tax_base *
+                                                             inv_factor) -
+                                                            (tax_amount *
+                                                             inv_factor))
+                                                added = True
+                                                break
+                                        if not added:
+                                            line[1].append({
+                                                'name': tax_line.name,
+                                                'base':
+                                                    (tax_base * inv_factor),
+                                                'amount':
+                                                    -(tax_amount * inv_factor),
+                                                'total': ((
+                                                    tax_base * inv_factor) -
+                                                    (tax_amount * inv_factor)
+                                                    )})
+                                            line[2] += tax_base * inv_factor
+                                            line[3] -= tax_amount * inv_factor
+                                            line[4] += ((tax_base * inv_factor)
+                                                        - (tax_amount *
+                                                           inv_factor))
+                                            added = True
+                                        break
+                                if not added:
+                                    self.out_invoices.append([curr, [{
+                                        'name': tax_line.name,
+                                        'base': (tax_base * inv_factor),
+                                        'amount': -(tax_amount * inv_factor),
+                                        'total':
+                                            ((tax_base * inv_factor) -
+                                             (tax_amount * inv_factor))}],
+                                        (tax_base * inv_factor),
+                                        -(tax_amount * inv_factor),
+                                        ((tax_base * inv_factor) -
+                                         (tax_amount * inv_factor))])
+                                continue
+                            # Caso normal
+                            if tax_line.name in dic_tax_lines:
+                                dic_tax_lines.update({
+                                    tax_line.name: {
+                                        'name': tax_line.name,
+                                        'base':
+                                            (dic_tax_lines[tax_line.name]
+                                             ['base'] +
+                                             (tax_base * inv_factor)),
+                                        'amount': dic_tax_lines[tax_line.name]
+                                            ['amount'] + (tax_amount *
+                                                          inv_factor),
+                                        'total': dic_tax_lines[tax_line.name]
+                                            ['total'] +
+                                            ((tax_base * inv_factor) +
+                                             (tax_amount * inv_factor))}
+                                })
+                            else:
+                                dic_tax_lines.update({
+                                    tax_line.name: {
+                                        'name': tax_line.name,
+                                        'base': (tax_base * inv_factor),
+                                        'amount': (tax_amount * inv_factor),
+                                        'total':
+                                            ((tax_base * inv_factor) +
+                                             (tax_amount * inv_factor))}
+                                })
+                            base += (tax_base * inv_factor)
+                            amount += (tax_amount * inv_factor)
+                            total += ((tax_base * inv_factor) +
+                                      (tax_amount * inv_factor))
+                for tax in dic_tax_lines:
+                    tax_lines.append(dic_tax_lines[tax])
+            # Append the tuple to the property
+            dest.append([curr, tax_lines, base, amount, total])
+        del tmp
+
+    def calculate_differences(self, dest, in_invoices, out_invoices):
+        dic_lines = {}
+        #
+        # Compute the total for each currency group
+        #
+        for line_out in out_invoices:
+            if line_out[0] in dic_lines:
+                dic_lines.update({
+                    line_out[0]: {
+                        'currency': line_out[0],
+                        'base': dic_lines[line_out[0]]['base'] + line_out[2],
+                        'amount':
+                            dic_lines[line_out[0]]['amount'] + line_out[3],
+                        'total': dic_lines[line_out[0]]['total'] + line_out[4],
+                        'text': ((
+                            dic_lines[line_out[0]]['amount'] +
+                            line_out[3]) >= 0 and
+                            _('TO ENTERED') or _('TO RETURNED'))}
+                })
+            else:
+                dic_lines.update({
+                    line_out[0]: {
+                        'currency': line_out[0],
+                        'base': line_out[2],
+                        'amount': line_out[3],
+                        'total': line_out[4],
+                        'text': (line_out[3] >= 0 and
+                                 _('TO ENTERED') or _('TO RETURNED')),
+                        }
+                })
+        for line_in in in_invoices:
+            if line_in[0] in dic_lines:
+                dic_lines.update({
+                    line_in[0]: {
+                        'currency': line_in[0],
+                        'base': dic_lines[line_in[0]]['base'] - line_in[2],
+                        'amount': dic_lines[line_in[0]]['amount'] - line_in[3],
+                        'total': dic_lines[line_in[0]]['total'] - line_in[4],
+                        'text': ((dic_lines[line_in[0]]['amount'] -
+                                  line_in[3]) >= 0 and
+                                 _('TO ENTERED') or _('TO RETURNED'))}
+                })
+            else:
+                dic_lines.update({
+                    line_in[0]: {
+                        'currency': line_in[0],
+                        'base': -line_in[2],
+                        'amount': -line_in[3],
+                        'total': -line_in[4],
+                        'text': -line_in[3] >= 0 and
+                        _('TO ENTERED') or _('TO RETURNED'),
+                        }
+                })
+        # Return total difference
+        for line in dic_lines:
+            # Append the tuple to the property
+            dest.append(dic_lines[line])
+
+report_sxw.report_sxw('report.account.vat.clearance.list.report',
+                      'account.invoice', 'addons/dos_vat_clearance_report/'
+                      'report/vat_clearance_list.rml',
+                      parser=PrintVatClearanceList, header=False)

=== added directory 'dos_vat_clearance_report/views'
=== renamed file 'dos_vat_clearance_report/account_tax_code_view.xml' => 'dos_vat_clearance_report/views/account_tax_code_view.xml'
--- dos_vat_clearance_report/account_tax_code_view.xml	2014-06-11 10:23:47 +0000
+++ dos_vat_clearance_report/views/account_tax_code_view.xml	2014-07-09 07:36:58 +0000
@@ -7,7 +7,6 @@
 			<field name="name">account.tax.code.irpf.form</field>
 			<field name="model">account.tax.code</field>
 			<field name="inherit_id" ref="account.view_tax_code_form"/>
-			<field name="type">form</field>
 			<field name="arch" type="xml">
 				<field name="company_id" position="after">
 					<field name="irpf"/>

=== renamed file 'dos_vat_clearance_report/account_report_wizard.xml' => 'dos_vat_clearance_report/wizard/account_report_wizard.xml'
--- dos_vat_clearance_report/account_report_wizard.xml	2014-06-11 10:23:47 +0000
+++ dos_vat_clearance_report/wizard/account_report_wizard.xml	2014-07-09 07:36:58 +0000
@@ -1,22 +1,65 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <openerp>
-  <data >
-
-	# Report Vat Clearance
-        <wizard
-            string="Print Vat Clearance List"
-            model="account.invoice"
-            name="account.vat.clearance.report"
-            menu="False"
-            id="wizard_vat_clearance_report"/>
-			
-		<menuitem
-            name="Print Vat Clearance List"
-            parent="account.menu_finance_generic_reporting"
-            action="wizard_vat_clearance_report"
-            type="wizard"
-            icon="STOCK_PRINT"
-            id="menu_vat_clearance_report"/>
-
-  </data>
+	<data>
+		<record model="ir.ui.view" id="wizard_vat_clearance_report_form_view">
+			<field name="name">wizard.vat.clearance.report</field>
+			<field name="model">wizard.vat.clearance.report</field>
+			<field name="arch" type="xml">
+
+				<form string="Vat Clearance List">
+					<field name="company_id" />
+					<newline />
+					<field name="report_name" required="True" />
+					<newline />
+					<group colspan="4">
+						<separator string="Filter by type" colspan="4" />
+						<field name="out_invoice" />
+						<field name="out_refund" />
+						<field name="in_invoice" />
+						<field name="in_refund" />
+					</group>
+					<group colspan="4">
+						<separator string="Filter by state" colspan="4" />
+						<field name="draft" />
+						<field name="proforma" />
+						<field name="open" />
+						<field name="paid" />
+						<field name="cancel" />
+					</group>
+					<group colspan="4">
+						<separator string="Filter by date (default current year)"
+							colspan="4" />
+						<field name="state" required="True" />
+						<newline />
+						<group attrs="{'invisible':[('state','=','none')]}" colspan="4">
+							<group attrs="{'invisible':[('state','=','byperiod')]}"
+								colspan="4">
+								<separator string="Date Filter" colspan="4" />
+								<field name="date_from" />
+								<field name="date_to" />
+							</group>
+							<group attrs="{'invisible':[('state','=','bydate')]}"
+								colspan="4">
+								<separator string="Filter on Periods" colspan="4" />
+								<field name="periods" colspan="4" nolabel="1" />
+							</group>
+						</group>
+					</group>
+					<group colspan="4">
+						<separator string="Options" colspan="4" />
+						<field name="vat_taxes" required="False" />
+						<field name="irpf_taxes" required="False" />
+					</group>
+				</form>
+			</field>
+		</record>
+		<wizard string="Print Vat Clearance List" model="account.invoice"
+			name="account.vat.clearance.report" menu="False"
+			id="wizard_vat_clearance_report" />
+
+		<menuitem name="Print Vat Clearance List" parent="account.menu_finance_generic_reporting"
+			action="wizard_vat_clearance_report" type="wizard" icon="STOCK_PRINT"
+			id="menu_vat_clearance_report" />
+
+	</data>
 </openerp>

=== modified file 'dos_vat_clearance_report/wizard/wizard_vat_clearance_report.py'
--- dos_vat_clearance_report/wizard/wizard_vat_clearance_report.py	2014-06-11 10:23:47 +0000
+++ dos_vat_clearance_report/wizard/wizard_vat_clearance_report.py	2014-07-09 07:36:58 +0000
@@ -21,10 +21,9 @@
 #
 ##############################################################################
 
-import wizard
-import pooler
+from openerp.osv import orm,fields
 import time
-from tools.translate import _
+from openerp.tools.translate import _
 
 period_form = '''<?xml version="1.0"?>
 <form string="Vat Clearance List">
@@ -96,18 +95,54 @@
 }
 
 
-
-class wizard_report(wizard.interface):
-    def _get_defaults(self, cr, uid, data, context={}):
-        user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
+class WizardVatClearanceReport(orm.TransientModel):
+    
+    _name = 'wizard.vat.clearance.report'
+    
+    def _get_defaults(self, cr, uid, data, context=None):
+        user = self.pool['res.users'].browse(cr, uid, uid, context=context)
         if user.company_id:
             company_id = user.company_id.id
         else:
-            company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
+            company_id = self.pool['res.company'].search(
+                cr, uid, [('parent_id', '=', False)], context=context)[0]
         data['form']['company_id'] = company_id
         data['form']['context'] = context
-        return data['form']
+        return data['form']['company_id']
 
+    _columns = {
+                'company_id': fields.many2one('res.company', 'Company', required=True),
+                'out_invoice': fields.boolean('Customer invoices'),
+                'out_refund': fields.boolean('Customer refunds'),
+                'in_invoice': fields.boolean('Supplier invoices'),
+                'in_refund': fields.boolean('Supplier invoices'),
+                'draft': fields.boolean('Draft'),
+                'proforma': fields.boolean('Pro-forma'),
+                'open': fields.boolean('Open'),
+                'paid': fields.boolean('Done'),
+                'cancel': fields.boolean('Cancelled'),
+                'vat_taxes': fields.boolean('VAT taxes'),
+                'irpf_taxes': fields.boolean('IRPF taxes'),
+                'state': fields.selection([('bydate', 'By Date'), ('bypediod', 'By Period'), ('all', 'By Date and Period'), ('none', 'No Filter')], "Date/Period Filter"),
+                'periods': fields.many2many('account.period',string='Period'),
+                'date_from': fields.date('Start date'),
+                'date_to': fields.date('End date'),
+                'report_name': fields.char('Report Name', size=128)
+                }
+    _defaults = {
+                 'out_invoice': True,
+                 'out_refund': True,
+                 'in_invoice': True,
+                 'in_refund': True,
+                 'paid': True,
+                 'open': True,
+                 'vat_taxes': True,
+                 'state': 'none',
+                 'date_from': lambda *a: time.strftime('%Y-01-01'),
+                 'date_to': lambda *a: time.strftime('%Y-%m-%d'),
+                 'reort_name': _('Listado de liquidación de IVA'),
+                 'company_id': _get_defaults
+                 }
 
     states = {
         'init': {

=== modified file 'nayar_sepa_mandate/views/sdd_mandate_view.xml'
--- nayar_sepa_mandate/views/sdd_mandate_view.xml	2014-07-02 15:25:41 +0000
+++ nayar_sepa_mandate/views/sdd_mandate_view.xml	2014-07-09 07:36:58 +0000
@@ -12,9 +12,7 @@
             <field name="inherit_id"
                 ref="account_payment_sepa_direct_debit.sdd_mandate_form" />
             <field name="arch" type="xml">
-                <group colspan="4" position="replace" />
-                <field name="company_id" position="before">
-                    <field name="unique_mandate_reference" />
+                <field name="type" position="before">
                     <field name="sdd_scheme" />
                 </field>
             </field>


Follow ups