addinglu
authorFabien Pinckaers <fp@tinyerp.com>
Tue, 14 Oct 2008 14:08:35 +0000 (16:08 +0200)
committerFabien Pinckaers <fp@tinyerp.com>
Tue, 14 Oct 2008 14:08:35 +0000 (16:08 +0200)
bzr revid: fp@tinyerp.com-20081014140835-lxeorwpgogchitnc

addons/l10n_lu/__terp__.py
addons/l10n_lu/l10n_lu_report.xml [new file with mode: 0644]
addons/l10n_lu/l10n_lu_wizard.xml
addons/l10n_lu/wizard/__init__.py [new file with mode: 0644]
addons/l10n_lu/wizard/print_vat.py [new file with mode: 0644]

index 61d131c..70f9036 100644 (file)
@@ -10,7 +10,7 @@ This module install:
     *the KLUWER Chart of Accounts,
     *the Tax Code Chart for Luxembourg
     *the main taxes used in Luxembourg""",
-        "depends" : ["account","base"],
+        "depends" : ["account","account_report"],
         "init_xml" : [ ],
         "demo_xml" : [ "account.report.report.csv" ],
         "update_xml" : [
diff --git a/addons/l10n_lu/l10n_lu_report.xml b/addons/l10n_lu/l10n_lu_report.xml
new file mode 100644 (file)
index 0000000..192b603
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <report
+            auto="False"
+            id="legal_vat"
+            menu="False"
+            model="account.tax.code"
+            name="l10n_lu.tax.report.print"
+            string="Luxemburg VAT Declaration"/>
+    </data>
+</openerp>
index 6820911..127ff4a 100644 (file)
@@ -10,21 +10,22 @@ This is the same wizard that runs from Financial Managament/Configuration/Financ
         <field name="state">open</field>
     </record>
 
-        <menuitem 
-            id="legal_lu"
-            parent="account.menu_finance_legal_statement"
-            name="Luxemburg"/>
+    <menuitem
+        id="legal_lu"
+        parent="account.menu_finance_legal_statement"
+        name="Luxemburg"/>
 
-        <wizard
-            id="wizard_print_vat"
-            menu="False"
-            model="account.tax.code"
-            name="l10n_lu.tax.report.wizard" string="Luxemburg VAT Declaration"/>
+    <wizard
+        id="wizard_print_vat"
+        menu="False"
+        model="account.tax.code"
+        name="l10n_lu.tax.report.wizard" string="Luxemburg VAT Declaration"/>
 
-        <menuitem 
-            id="legal_lu_vat"
-            parent="legal_lu"
-            action="wizard_print_vat"/>
+    <menuitem 
+        id="legal_lu_vat"
+        parent="legal_lu"
+        type="wizard"
+        action="wizard_print_vat"/>
 
 
     </data>
diff --git a/addons/l10n_lu/wizard/__init__.py b/addons/l10n_lu/wizard/__init__.py
new file mode 100644 (file)
index 0000000..0ff0d08
--- /dev/null
@@ -0,0 +1 @@
+import print_vat
diff --git a/addons/l10n_lu/wizard/print_vat.py b/addons/l10n_lu/wizard/print_vat.py
new file mode 100644 (file)
index 0000000..1060939
--- /dev/null
@@ -0,0 +1,81 @@
+# -*- encoding: utf-8 -*-
+#Copyright (c) Vincent Cardon <vincent.cardon@tranquil-it-systems.fr>
+# Denis Cardon <denis.cardon@tranquilitsystems.com> and Emmanuel RICHARD.
+#Ingenieur fondateur
+#Tranquil IT Systems
+
+
+import wizard
+import time
+import datetime
+import pooler
+import sys
+from mx.DateTime import *
+import tools
+from report.render import render 
+from report.interface import report_int
+import os
+
+_tax_form = """<?xml version="1.0"?>
+<form string="VAT Legal Declaration">
+    <field name="tax_code_id"/>
+    <field name="period_id"/>
+</form>"""
+
+_tax_fields = {
+    'tax_code_id': {
+        'string': 'Company',
+        'type': 'many2one',
+        'relation': 'account.tax.code',
+        'required': True,
+        'domain': [('parent_id','=',False)]},
+    'period_id': {
+        'string':'Period',
+        'type': 'many2one',
+        'relation': 'account.period',
+        'required':True
+    }
+}
+
+class external_pdf(render):
+    def __init__(self, pdf):
+        render.__init__(self)
+        self.pdf = pdf
+        self.output_type='pdf'
+    def _render(self):
+        return self.pdf
+
+
+class report_custom(report_int):
+    def create(self, cr, uid, ids, datas, context={}):
+        print datas, ids, uid
+
+        taxobj = self.pool.get('account.tax.code')
+        code_ids = taxobj.search(cr, uid, [('parent_id','child_of',[datas['form']['tax_code_id']])])
+        result = {}
+        for t in taxobj.browse(cr, uid, code_ids, {'period_id': datas['form']['period_id']}):
+            if t.code:
+                result[t.code] = t.sum_period
+        os.system('pdftk... output /tmp/tax.pdf')
+        self.obj = external_pdf(file('/tmp/tax.pdf').read())
+        self.obj.render()
+
+        pdf_string.close()
+        return (self.obj.pdf, 'pdf')
+
+report_custom('report.l10n_lu.tax.report.print')
+
+
+class wizard_report(wizard.interface):
+    states = {
+        'init': {
+             'actions': [],
+             'result': {'type':'form', 'arch':_tax_form, 'fields':_tax_fields, 'state':[('end','Cancel'),('pdf','Print Balance Sheet')]},
+        },
+        'pdf': {
+            'actions': [],
+            'result': {'type':'print', 'report': 'l10n_lu.tax.report.print', 'state':'end'},
+        },
+    }
+wizard_report('l10n_lu.tax.report.wizard')
+