[FIX] l10n_be : Wizards corrected in order to allow accented characters

bzr revid: jvo@tinyerp.com-20100823194916-dbqboguw2avbo6aq
This commit is contained in:
Jay (OpenERP) 2010-08-24 01:19:16 +05:30
parent 9298971abc
commit ecc8cce797
5 changed files with 30 additions and 37 deletions

View File

@ -1,6 +1,3 @@
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# -*- coding: utf-8 -*-
##############################################################################
#
@ -25,7 +22,6 @@ import time
import base64
from tools.translate import _
import tools
from osv import fields, osv
class vat_listing_clients(osv.osv_memory):
@ -143,7 +139,7 @@ class partner_vat_list(osv.osv_memory):
}
def create_xml(self, cursor, user, ids, context={}):
datas=[]
datas = []
obj_sequence = self.pool.get('ir.sequence')
obj_users = self.pool.get('res.users')
obj_partner = self.pool.get('res.partner')
@ -178,16 +174,16 @@ class partner_vat_list(osv.osv_memory):
country = ads.country_id.code
sender_date = time.strftime('%Y-%m-%d')
comp_name = obj_cmpny.name
data_file = '<?xml version="1.0"?>\n<VatList xmlns="http://www.minfin.fgov.be/VatList" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.minfin.fgov.be/VatList VatList.xml" RecipientId="VAT-ADMIN" SenderId="'+ str(company_vat) + '"'
data_file +=' ControlRef="'+ cref + '" MandataireId="'+ tools.ustr(context['mand_id']) + '" SenderDate="'+ str(sender_date)+ '"'
data_file +=' ControlRef="'+ cref + '" MandataireId="'+ context['mand_id'] + '" SenderDate="'+ str(sender_date)+ '"'
if ['test_xml']:
data_file += ' Test="0"'
data_file += ' VersionTech="1.2">'
data_file += '\n<AgentRepr DecNumber="1">\n\t<CompanyInfo>\n\t\t<VATNum>'+str(company_vat)+'</VATNum>\n\t\t<Name>'+tools.ustr(obj_cmpny.name)+'</Name>\n\t\t<Street>'+ tools.ustr(street) +'</Street>\n\t\t<CityAndZipCode>'+ tools.ustr(zip_city) +'</CityAndZipCode>'
data_file += '\n\t\t<Country>'+ tools.ustr(country) +'</Country>\n\t</CompanyInfo>\n</AgentRepr>'
data_comp = '\n<CompanyInfo>\n\t<VATNum>'+str(company_vat)+'</VATNum>\n\t<Name>'+tools.ustr(obj_cmpny.name)+'</Name>\n\t<Street>'+ tools.ustr(street) +'</Street>\n\t<CityAndZipCode>'+ tools.ustr(zip_city) +'</CityAndZipCode>\n\t<Country>'+ tools.ustr(country) +'</Country>\n</CompanyInfo>'
data_period = '\n<Period>'+ tools.ustr(obj_year.date_stop[:4]) +'</Period>'
data_file += '\n<AgentRepr DecNumber="1">\n\t<CompanyInfo>\n\t\t<VATNum>'+str(company_vat)+'</VATNum>\n\t\t<Name>'+ comp_name +'</Name>\n\t\t<Street>'+ street +'</Street>\n\t\t<CityAndZipCode>'+ zip_city +'</CityAndZipCode>'
data_file += '\n\t\t<Country>'+ country +'</Country>\n\t</CompanyInfo>\n</AgentRepr>'
data_comp = '\n<CompanyInfo>\n\t<VATNum>'+str(company_vat)+'</VATNum>\n\t<Name>'+ comp_name +'</Name>\n\t<Street>'+ street +'</Street>\n\t<CityAndZipCode>'+ zip_city +'</CityAndZipCode>\n\t<Country>'+ country +'</Country>\n</CompanyInfo>'
data_period = '\n<Period>'+ obj_year.date_stop[:4] +'</Period>'
error_message = []
data = self.read(cursor, user, ids)[0]
for partner in data['partner_ids']:
@ -207,13 +203,13 @@ class partner_vat_list(osv.osv_memory):
continue
if line['turnover'] < context['limit_amount']:
continue
seq +=1
sum_tax +=line['amount']
sum_turnover +=line['turnover']
data_clientinfo +='\n<ClientList SequenceNum="'+str(seq)+'">\n\t<CompanyInfo>\n\t\t<VATNum>'+line['vat'] +'</VATNum>\n\t\t<Country>'+tools.ustr(line['country']) +'</Country>\n\t</CompanyInfo>\n\t<Amount>'+str(int(line['amount'] * 100)) +'</Amount>\n\t<TurnOver>'+str(int(line['turnover'] * 100)) +'</TurnOver>\n</ClientList>'
seq += 1
sum_tax += line['amount']
sum_turnover += line['turnover']
data_clientinfo += '\n<ClientList SequenceNum="'+str(seq)+'">\n\t<CompanyInfo>\n\t\t<VATNum>'+line['vat'] +'</VATNum>\n\t\t<Country>' + line['country'] +'</Country>\n\t</CompanyInfo>\n\t<Amount>'+str(int(line['amount'] * 100)) +'</Amount>\n\t<TurnOver>'+str(int(line['turnover'] * 100)) +'</TurnOver>\n</ClientList>'
data_decl ='\n<DeclarantList SequenceNum="1" DeclarantNum="'+ dnum + '" ClientNbr="'+ str(seq) +'" TurnOverSum="'+ str(int(sum_turnover * 100)) +'" TaxSum="'+ str(int(sum_tax * 100)) +'" />'
data_file += tools.ustr(data_decl) + tools.ustr(data_comp) + tools.ustr(data_period) + tools.ustr(data_clientinfo) + '\n</VatList>'
data_file += data_decl + data_comp + str(data_period) + data_clientinfo + '\n</VatList>'
msg = 'Save the File with '".xml"' extension.'
file_save = base64.encodestring(data_file.encode('utf8'))
self.write(cursor, user, ids, {'file_save':file_save, 'msg':msg, 'name':'vat_list.xml'}, context=context)

View File

@ -30,7 +30,7 @@ class l10n_be_vat_declaration(osv.osv_memory):
def _get_xml_data(self, cr, uid, context=None):
if context.get('file_save', False):
return base64.encodestring(context['file_save'])
return base64.encodestring(context['file_save'].encode('utf8'))
return ''
_columns = {
@ -47,21 +47,19 @@ class l10n_be_vat_declaration(osv.osv_memory):
'msg': 'Save the File with '".xml"' extension.',
'file_save': _get_xml_data,
'name': 'vat_declaration.xml',
}
}
def create_xml(self, cr, uid, ids, context=None):
obj_fyear = self.pool.get('account.fiscalyear')
obj_tax_code = self.pool.get('account.tax.code')
obj_acc_period = self.pool.get('account.period')
obj_user = self.pool.get('res.users')
obj_comp = self.pool.get('res.company')
obj_data = self.pool.get('ir.model.data')
mod_obj = self.pool.get('ir.model.data')
if context is None:
context = {}
list_of_tags=['00','01','02','03','44','45','46','47','48','49','54','55','56','57','59','61','62','63','64','71','81','82','83','84','85','86','87','88','91']
list_of_tags = ['00','01','02','03','44','45','46','47','48','49','54','55','56','57','59','61','62','63','64','71','81','82','83','84','85','86','87','88','91']
data_tax = self.browse(cr, uid, ids[0])
if data_tax.tax_code_id:
obj_company = data_tax.tax_code_id.company_id
@ -70,8 +68,7 @@ class l10n_be_vat_declaration(osv.osv_memory):
user_cmpny = obj_company.name
vat_no = obj_company.partner_id.vat
if not vat_no:
raise osv.except_osv(_('Data Insufficient'), _('No VAT Number Associated with Main Company!'))
raise osv.except_osv(_('Data Insufficient'), _('No VAT Number Associated with Main Company!'))
tax_code_ids = obj_tax_code.search(cr, uid, [], context=context)
ctx = context.copy()
@ -80,15 +77,15 @@ class l10n_be_vat_declaration(osv.osv_memory):
tax_info = obj_tax_code.read(cr, uid, tax_code_ids, ['code','sum_period'], context=ctx)
address = post_code = city = country_code = ''
city, post_code, address, country_code =self.pool.get('res.company')._get_default_ad(obj_company.partner_id.address)
city, post_code, address, country_code = self.pool.get('res.company')._get_default_ad(obj_company.partner_id.address)
year_id = obj_fyear.find(cr, uid)
account_period = obj_acc_period.browse(cr, uid, data['period_id'], context=context)
period_code = account_period.code
send_ref = str(obj_company.partner_id.id) + str(account_period.date_start[5:7]) + str(account_period.date_stop[:4])
data_of_file='<?xml version="1.0"?>\n<VATSENDING xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MultiDeclarationTVA-NoSignature-14.xml">'
data_of_file +='\n\t<DECLARER>\n\t\t<VATNUMBER>'+str(vat_no)+'</VATNUMBER>\n\t\t<NAME>'+str(obj_company.name)+'</NAME>\n\t\t<ADDRESS>'+address+'</ADDRESS>'
data_of_file = '<?xml version="1.0"?>\n<VATSENDING xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MultiDeclarationTVA-NoSignature-14.xml">'
data_of_file +='\n\t<DECLARER>\n\t\t<VATNUMBER>'+str(vat_no)+'</VATNUMBER>\n\t\t<NAME>'+ obj_company.name +'</NAME>\n\t\t<ADDRESS>'+address+'</ADDRESS>'
data_of_file +='\n\t\t<POSTCODE>'+post_code+'</POSTCODE>\n\t\t<CITY>'+city+'</CITY>\n\t\t<COUNTRY>'+country_code+'</COUNTRY>\n\t\t<SENDINGREFERENCE>'+send_ref+'</SENDINGREFERENCE>\n\t</DECLARER>'
data_of_file +='\n\t<VATRECORD>\n\t\t<RECNUM>1</RECNUM>\n\t\t<VATNUMBER>'+((vat_no and str(vat_no[2:])) or '')+'</VATNUMBER>\n\t\t<DPERIODE>\n\t\t\t'
@ -115,7 +112,7 @@ class l10n_be_vat_declaration(osv.osv_memory):
if item['code'] in list_of_tags:
data_of_file +='\n\t\t\t\t<D'+str(int(item['code'])) +'>' + str(abs(int(item['sum_period']*100))) + '</D'+str(int(item['code'])) +'>'
data_of_file +='\n\t\t\t</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>'
data_of_file += '\n\t\t\t</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>'
model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_vat_save')], context=context)
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
context['file_save'] = data_of_file

View File

@ -38,7 +38,7 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Save xml">
<group height="200" width="310">
<group height="200" width="400">
<separator colspan="2" string="Note: "/><newline/>
<label string="Save the File with '.xml' extension." colspan="2" align="0.0"/><newline/>
<field name="name"/><newline/>

View File

@ -66,7 +66,7 @@
<newline/>
<field name="file_save" />
<separator colspan="4"/>
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button special="cancel" string="Close" icon="gtk-cancel"/>
</form>
</field>
</record>

View File

@ -33,7 +33,7 @@ class partner_vat_intra(osv.osv_memory):
def _get_xml_data(self, cr, uid, context=None):
if context.get('file_save', False):
return base64.encodestring(context['file_save'])
return base64.encodestring(context['file_save'].encode('utf8'))
return ''
def _get_europe_country(self, cursor, user, context=None):
@ -64,7 +64,7 @@ class partner_vat_intra(osv.osv_memory):
'country_ids': _get_europe_country,
'file_save': _get_xml_data,
'name': 'vat_Intra.xml',
}
}
def create_xml(self, cursor, user, ids, context=None):
obj_user = self.pool.get('res.users')
@ -72,7 +72,6 @@ class partner_vat_intra(osv.osv_memory):
obj_sequence = self.pool.get('ir.sequence')
obj_partner = self.pool.get('res.partner')
obj_partner_add = self.pool.get('res.partner.address')
obj_country = self.pool.get('res.country')
mod_obj = self.pool.get('ir.model.data')
street = zip_city = country = p_list = data_clientinfo = ''
error_message = list_partner = []
@ -111,13 +110,14 @@ class partner_vat_intra(osv.osv_memory):
if ads.country_id:
country = ads.country_id.code
comp_name = data_cmpny.name
sender_date = time.strftime('%Y-%m-%d')
data_file = '<?xml version="1.0"?>\n<VatIntra xmlns="http://www.minfin.fgov.be/VatIntra" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" RecipientId="VAT-ADMIN" SenderId="' + str(company_vat) + '"'
data_file +=' ControlRef="' + cref + '" MandataireId="' + data['mand_id'] + '" SenderDate="'+ str(sender_date)+ '"'
data_file += ' ControlRef="' + cref + '" MandataireId="' + data['mand_id'] + '" SenderDate="'+ str(sender_date)+ '"'
data_file += ' VersionTech="1.3">'
data_file +='\n\t<AgentRepr DecNumber="1">\n\t\t<CompanyInfo>\n\t\t\t<VATNum>' + str(company_vat)+'</VATNum>\n\t\t\t<Name>'+str(data_cmpny.name)+'</Name>\n\t\t\t<Street>'+ str(street) +'</Street>\n\t\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>'
data_file +='\n\t\t\t<Country>' + str(country) +'</Country>\n\t\t</CompanyInfo>\n\t</AgentRepr>'
data_comp ='\n\t\t<CompanyInfo>\n\t\t\t<VATNum>'+str(company_vat[2:])+'</VATNum>\n\t\t\t<Name>'+str(data_cmpny.name)+'</Name>\n\t\t\t<Street>'+ str(street) +'</Street>\n\t\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>\n\t\t\t<Country>'+ str(country) +'</Country>\n\t\t</CompanyInfo>'
data_file += '\n\t<AgentRepr DecNumber="1">\n\t\t<CompanyInfo>\n\t\t\t<VATNum>' + str(company_vat)+'</VATNum>\n\t\t\t<Name>'+ comp_name +'</Name>\n\t\t\t<Street>'+ street +'</Street>\n\t\t\t<CityAndZipCode>'+ zip_city +'</CityAndZipCode>'
data_file += '\n\t\t\t<Country>' + country +'</Country>\n\t\t</CompanyInfo>\n\t</AgentRepr>'
data_comp = '\n\t\t<CompanyInfo>\n\t\t\t<VATNum>'+str(company_vat[2:])+'</VATNum>\n\t\t\t<Name>'+ comp_name +'</Name>\n\t\t\t<Street>'+ street +'</Street>\n\t\t\t<CityAndZipCode>'+ zip_city +'</CityAndZipCode>\n\t\t\t<Country>'+ country +'</Country>\n\t\t</CompanyInfo>'
data_period = '\n\t\t<Period>'+ data['period_code'] +'</Period>' #trimester
p_id_list = obj_partner.search(cursor, user, [('vat','!=',False)])
if not p_id_list:
@ -144,7 +144,7 @@ class partner_vat_intra(osv.osv_memory):
data_clientinfo +='\n\t\t<ClientList SequenceNum="'+str(seq)+'">\n\t\t\t<CompanyInfo>\n\t\t\t\t<VATNum>'+row['vat'][2:] +'</VATNum>\n\t\t\t\t<Country>'+row['vat'][:2] +'</Country>\n\t\t\t</CompanyInfo>\n\t\t\t<Amount>'+str(amt) +'</Amount>\n\t\t\t<Code>'+str(intra_code) +'</Code>\n\t\t</ClientList>'
amount_sum = int(amount_sum)
data_decl = '\n\t<DeclarantList SequenceNum="1" DeclarantNum="'+ dnum + '" ClientNbr="'+ str(seq) +'" AmountSum="'+ str(amount_sum) +'" >'
data_file += str(data_decl) + str(data_comp) + str(data_period) + str(data_clientinfo) + '\n\t</DeclarantList>\n</VatIntra>'
data_file += data_decl + data_comp + str(data_period) + data_clientinfo + '\n\t</DeclarantList>\n</VatIntra>'
model_data_ids = mod_obj.search(cursor, user,[('model','=','ir.ui.view'),('name','=','view_vat_intra_save')], context=context)
resource_id = mod_obj.read(cursor, user, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
context['file_save'] = data_file