From a33826ac52502d7ee3b7bfc7720e2228744131af Mon Sep 17 00:00:00 2001 From: pinky <> Date: Fri, 8 Dec 2006 13:03:08 +0000 Subject: [PATCH] l10n_ch : DTA and V11 first version bzr revid: pinky-cc537050293435f32b59349ebd142bbed4482e93 --- addons/l10n_ch/__init__.py | 1 + addons/l10n_ch/__terp__.py | 7 +- addons/l10n_ch/dta/__init__.py | 2 +- addons/l10n_ch/dta/__terp__.py | 13 ++ addons/l10n_ch/dta/dta.py | 38 ++++ addons/l10n_ch/dta/dta_view.xml | 28 +++ addons/l10n_ch/dta/dta_wizard.xml | 9 + addons/l10n_ch/dta/wizard_dta.py | 42 +++++ addons/l10n_ch/v11/__init__.py | 29 ++++ addons/l10n_ch/v11/v11.py | 40 +++++ addons/l10n_ch/v11/v11_import.py | 212 +++++++++++++++++++++++ addons/l10n_ch/v11/v11_view.xml | 37 ++++ addons/l10n_ch/v11/v11_wizard.xml | 15 ++ addons/l10n_ch_pcpbl_plangen/__terp__.py | 2 +- 14 files changed, 470 insertions(+), 5 deletions(-) create mode 100644 addons/l10n_ch/dta/__terp__.py create mode 100644 addons/l10n_ch/dta/dta.py create mode 100644 addons/l10n_ch/dta/dta_view.xml create mode 100644 addons/l10n_ch/dta/dta_wizard.xml create mode 100644 addons/l10n_ch/dta/wizard_dta.py create mode 100644 addons/l10n_ch/v11/__init__.py create mode 100644 addons/l10n_ch/v11/v11.py create mode 100644 addons/l10n_ch/v11/v11_import.py create mode 100644 addons/l10n_ch/v11/v11_view.xml create mode 100644 addons/l10n_ch/v11/v11_wizard.xml diff --git a/addons/l10n_ch/__init__.py b/addons/l10n_ch/__init__.py index 177c5068d65..f0c82885192 100755 --- a/addons/l10n_ch/__init__.py +++ b/addons/l10n_ch/__init__.py @@ -28,3 +28,4 @@ import bvr import dta +import v11 diff --git a/addons/l10n_ch/__terp__.py b/addons/l10n_ch/__terp__.py index be0fc214a94..80dc95baf8e 100755 --- a/addons/l10n_ch/__terp__.py +++ b/addons/l10n_ch/__terp__.py @@ -8,9 +8,10 @@ "category" : "Localisation/Europe", "website": "http://www.tinyerp.com", "depends" : ["base", "account"], - "init_xml" : ["zip_code_default.xml"], + "init_xml" : [],#"zip_code_default.xml" "demo_xml" : ["vaudtax_data_demo.xml"], - "update_xml" : ["vaudtax_data.xml","account_vat.xml","base_config.xml","account_config.xml"], + # "update_xml" : ["vaudtax_data.xml","account_vat.xml","base_config.xml","account_config.xml"], + "update_xml" : ["dta/dta_view.xml","v11/v11_view.xml","v11/v11_wizard.xml"], "active": False, - "installable": True + "installable": True, } diff --git a/addons/l10n_ch/dta/__init__.py b/addons/l10n_ch/dta/__init__.py index bfa4e78022e..be8faac5f52 100755 --- a/addons/l10n_ch/dta/__init__.py +++ b/addons/l10n_ch/dta/__init__.py @@ -25,4 +25,4 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## - +import dta diff --git a/addons/l10n_ch/dta/__terp__.py b/addons/l10n_ch/dta/__terp__.py new file mode 100644 index 00000000000..907f2955c10 --- /dev/null +++ b/addons/l10n_ch/dta/__terp__.py @@ -0,0 +1,13 @@ +{ + "name" : "DTA file creation", + "version" : "1.0", + "author" : "Tiny", + "website" : "", + "depends" : ["l10n_ch", "account"], + "category" : "Generic Modules/Accounting", + "init_xml" : [], + "demo_xml" : [], + "update_xml" : ["dta_view.xml"], + "active": True, + "installable": True +} diff --git a/addons/l10n_ch/dta/dta.py b/addons/l10n_ch/dta/dta.py new file mode 100644 index 00000000000..9f159f9051f --- /dev/null +++ b/addons/l10n_ch/dta/dta.py @@ -0,0 +1,38 @@ +############################################################################## +# +# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# 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 2 +# 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import time +from osv import osv,fields + +class account_dta(osv.osv): + _name = "account.dta" + _description = "DTA Management" + _columns = { + 'name': fields.binary('DTA file', readonly=True), + 'note': fields.text('Error log'), + } +account_dta() diff --git a/addons/l10n_ch/dta/dta_view.xml b/addons/l10n_ch/dta/dta_view.xml new file mode 100644 index 00000000000..be27af79e6b --- /dev/null +++ b/addons/l10n_ch/dta/dta_view.xml @@ -0,0 +1,28 @@ + + + + + + account.dta + account.dta + form + +
+ + + + + +
+ + + account.dta + account.dta + form + form,tree + + + + +
+
diff --git a/addons/l10n_ch/dta/dta_wizard.xml b/addons/l10n_ch/dta/dta_wizard.xml new file mode 100644 index 00000000000..a34b28a34e8 --- /dev/null +++ b/addons/l10n_ch/dta/dta_wizard.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/addons/l10n_ch/dta/wizard_dta.py b/addons/l10n_ch/dta/wizard_dta.py new file mode 100644 index 00000000000..93b11149cf1 --- /dev/null +++ b/addons/l10n_ch/dta/wizard_dta.py @@ -0,0 +1,42 @@ +############################################################################## +# +# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# 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 2 +# 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import wizard + + + + + + +class wizard_invoice_dta_create(wizard.interface): + states = { + 'init': { + 'actions': [], + 'result': {'type':'state', 'state':'end'} + } + } +wizard_invoice_confirm('account.invoice.dta.create') diff --git a/addons/l10n_ch/v11/__init__.py b/addons/l10n_ch/v11/__init__.py new file mode 100644 index 00000000000..47e8ba2f28b --- /dev/null +++ b/addons/l10n_ch/v11/__init__.py @@ -0,0 +1,29 @@ +##############################################################################py +# +# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved. +# Fabien Pinckaers +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# 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 2 +# 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## +import v11 +import v11_import diff --git a/addons/l10n_ch/v11/v11.py b/addons/l10n_ch/v11/v11.py new file mode 100644 index 00000000000..0d9ea2a45e6 --- /dev/null +++ b/addons/l10n_ch/v11/v11.py @@ -0,0 +1,40 @@ +############################################################################## +# +# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved. +# Fabien Pinckaers +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# 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 2 +# 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + + +from osv import osv, fields + +class account_v11(osv.osv): + _name ='account.v11' + _columns = { + 'file': fields.binary('V11 file'), + 'note': fields.text('Import log'), + } + +account_v11() + diff --git a/addons/l10n_ch/v11/v11_import.py b/addons/l10n_ch/v11/v11_import.py new file mode 100644 index 00000000000..da739b06fc0 --- /dev/null +++ b/addons/l10n_ch/v11/v11_import.py @@ -0,0 +1,212 @@ +############################################################################## +# +# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# 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 2 +# 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## +import pooler +import time +import wizard +import ir +from osv.osv import except_osv +import netsvc +from time import sleep +from base64 import b64decode + + +test_form = """ +
+ + + +""" + +test_fields = { + 'journal_id' : { + 'string':'Destination Journal', + 'type':'many2one', + 'relation':'account.journal', + 'required':True, +# 'domain':[('type','=','sale')] + }, + +} + + +def _v11_parsing(self, cr, uid, data, context): + + # TODO: + # - verifier que la ligne de somme coincide avec le reste + # - verifier que chaque est au bon format : que des num, + # bin nbre de num, ... ex: "123".isdigit() + # Attention : p-e dependant de la banque ... + + # TODO (trunk) : + + pool = pooler.get_pool(cr.dbname) + v11 = pool.get('account.v11').browse(cr, uid, data['ids'])[0] + + line="" + record={} + total={} + total_compute= 0 + rec_list=[] + + for char in b64decode(v11.file): + + if not char == '\n': + line += char + + else : + + record['genre'] = line[0:3] + + print line + print line[0:] + print record['genre'] + print + if record['genre'] == '999': + + + + total={'n_postal': line[3:12], + 'cle': line[12:39], + 'tot_montant': line[39:51], + 'nb_rec': line[51:63], + 'date_etabl': line[63:69], + 'tot_frais_encaissement': line[69:78], + } + + else : + + + record={'n_postal': line[3:12], + 'n_ref': line[12:39], + 'montant': line[39:49], + 'reserve': line[49:59], + 'date_remise': line[59:65], + 'date_comptable': line[65:71], + 'date_valeur': line[71:77], + 'internal_ref': line[77:87], + 'reserve2': line[87:96], + 'frais_encaissement': line[96:100], + } + + total_compute+= int(record['montant']) + rec_list.append( record ) + + line="" + + #for key in sorted(record.keys()): + #print key," : ", record[key] + + + # TODO : raise a correct error message + if not total_compute == int(total['tot_montant']): + raise except_osv('warning', 'Incoherent v11 file !') + else: + + period_id = pool.get('account.period').find(cr,uid, context=context) + if not period_id: + raise osv.except_osv('No period found !', 'Unable to find a valid period !') + period_id = period_id[0] + invoice_obj= pool.browse('account.invoice') + for rec in rec_list: + + move_id = pool.get('account.move').create(cr, uid, { + 'name': 'Imported from v11', + 'period_id': period_id, + 'journal_id': data['form']['journal_id'] + }) + + invoice_id= invoice_obj.search(cr,uid,[ ('number','=',rec['internal_ref']) ]) + invoice = invoice_obj.browse(cr, uid, invoice_id) + acc1 = invoice.partner_id.property_account_receivable + acc2 = journal.default_debit_account_id + + # + # Vérifier que tu recois bien un int, sinon [0] + # + + pool.get('account.move.line').create(cr,uid,{ + 'name': 'v11', + 'debit': 0, + 'credit': rec['montant'], + 'account_id': acc1, + 'move_id': move_id, + 'partner_id': invoice.partner_id.id, + 'date': time.strftime('%Y-%m-%d'), + 'period_id': period_id, + 'journal_id': data['form']['journal_id'] + + }) + pool.get('account.move.line').create(cr,uid,{ + 'name': 'v11', + 'debit': rec['montant'], + 'credit': 0, + 'account_id': acc2, + 'move_id': move_id, + 'partner_id': invoice.partner_id.id, + 'date': time.strftime('%Y-%m-%d'), + 'period_id': period_id, + 'journal_id': data['form']['journal_id'] + + }) + + + #print total + #print rec_list + + + return {} + + + + +class v11_import(wizard.interface): + states = { + 'init' : { + 'actions' : [], + 'result' : {'type' : 'form', + 'arch' : test_form, + 'fields' : test_fields, + 'state' : [('end', 'Cancel'),('extraction', 'Yes') ]} + }, + 'extraction' : { + 'actions' : [_v11_parsing], + 'result' : {'type' : 'state', 'state' : 'end'} + }, + +# 'result' : { +# 'actions' : [], +# 'result' : {'type' : 'form', +# 'state' : 'end'} +# }, + + + + } +v11_import("account.v11_import") + + + diff --git a/addons/l10n_ch/v11/v11_view.xml b/addons/l10n_ch/v11/v11_view.xml new file mode 100644 index 00000000000..0de126cd58f --- /dev/null +++ b/addons/l10n_ch/v11/v11_view.xml @@ -0,0 +1,37 @@ + + + + + + + + + + account.v11.form + account.v11 + form + +
+ + + + + +
+ + + + account.v11 + ir.actions.act_window + account.v11 + form + form,tree + + + + + + + +
+
diff --git a/addons/l10n_ch/v11/v11_wizard.xml b/addons/l10n_ch/v11/v11_wizard.xml new file mode 100644 index 00000000000..6b32ea31d92 --- /dev/null +++ b/addons/l10n_ch/v11/v11_wizard.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/addons/l10n_ch_pcpbl_plangen/__terp__.py b/addons/l10n_ch_pcpbl_plangen/__terp__.py index 4336b40f55b..96796d0c648 100755 --- a/addons/l10n_ch_pcpbl_plangen/__terp__.py +++ b/addons/l10n_ch_pcpbl_plangen/__terp__.py @@ -5,7 +5,7 @@ "category" : "Localisation/Account charts", "depends" : ["base", "account","l10n_ch"], "init_xml" : [], - "update_xml" : ["account_ch_plangen.xml"], +# "update_xml" : ["account_ch_plangen.xml"], "demo_xml" : [], "active": False }