[IMP] improved and modified the Partner VAT Intra wizard of l10n_be module

bzr revid: bde@tinyerp.com-20120118051256-wm9n4rp0ypmjcuiq
This commit is contained in:
Bharat Devnani (OpenERP) 2012-01-18 10:42:56 +05:30
parent 5b10b7022d
commit 966f688c3c
1 changed files with 39 additions and 20 deletions

View File

@ -82,7 +82,7 @@ class partner_vat_intra(osv.osv_memory):
obj_partner_add = self.pool.get('res.partner.address')
xmldict = {}
street = zip_city = country = p_list = data_clientinfo = ''
post_code = street = city = country = p_list = data_clientinfo = ''
seq = amount_sum = 0
wiz_data = self.browse(cr, uid, ids[0], context=context)
@ -114,11 +114,21 @@ class partner_vat_intra(osv.osv_memory):
dnum = cref + seq_declarantnum[-5:]
addr = obj_partner.address_get(cr, uid, [data_cmpny.partner_id.id], ['invoice'])
email = data_cmpny.partner_id.email
phone = data_cmpny.partner_id.phone
if email == False:
email = ''
if phone == False:
phone = ''
if addr.get('invoice',False):
ads = obj_partner_add.browse(cr, uid, [addr['invoice']])[0]
zip_city = (ads.city or '') + ' ' + (ads.zip or '')
if zip_city== ' ':
zip_city = ''
city = (ads.city or '')
post_code = (ads.zip or '')
if city == ' ':
city = ''
if post_code == ' ':
post_code = ''
if ads.street:
street = ads.street
if ads.street2:
@ -136,8 +146,11 @@ class partner_vat_intra(osv.osv_memory):
'mand_id': wiz_data.mand_id,
'sender_date': str(time.strftime('%Y-%m-%d')),
'street': street,
'zip_city': zip_city,
'city': city,
'post_code': post_code,
'country': country,
'email': email,
'phone': phone,
'period': wiz_data.period_code,
'clientlist': []
})
@ -186,30 +199,36 @@ class partner_vat_intra(osv.osv_memory):
"""
mod_obj = self.pool.get('ir.model.data')
xml_data = self._get_datas(cursor, user, ids, context=context)
month_quarter = xml_data['period'][:2]
year = xml_data['period'][2:]
data_file = ''
for country in xml_data['clientlist']:
if country['country'] == 'BE':
country['country'] = ''
else:
country['country'] = country['country']
# Can't we do this by etree?
data_head = """<?xml version="1.0"?>
<VatIntra xmlns="http://www.minfin.fgov.be/VatIntra" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" RecipientId="VAT-ADMIN" SenderId="%(company_vat)s" ControlRef="%(controlref)s" MandataireId="%(mand_id)s" SenderDate="%(sender_date)s" VersionTech="1.3">
<AgentRepr DecNumber="1">
<CompanyInfo>
<VATNum>%(company_vat)s</VATNum>
<Name>%(company_name)s</Name>
<Street>%(street)s</Street>
<CityAndZipCode>%(zip_city)s</CityAndZipCode>
<Country>%(country)s</Country>
</CompanyInfo>
</AgentRepr>""" % (xml_data)
data_comp_period = '\n\t\t<CompanyInfo>\n\t\t\t<VATNum>%(vatnum)s</VATNum>\n\t\t\t<Name>%(company_name)s</Name>\n\t\t\t<Street>%(street)s</Street>\n\t\t\t<CityAndZipCode>%(zip_city)s</CityAndZipCode>\n\t\t\t<Country>%(country)s</Country>\n\t\t</CompanyInfo>\n\t\t<Period>%(period)s</Period>' % (xml_data)
<IntraConsignment xmlns="http://www.minfin.fgov.be/IntraConsignment" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" RecipientId="VAT-ADMIN" SenderId="%(company_vat)s" ControlRef="%(controlref)s" IntraListingsNbr="%(mand_id)s" SenderDate="%(sender_date)s" VersionTech="1.3">
<Representative>%(company_name)s</Representative>
<RepresentativeReference>%(mand_id)s</RepresentativeReference>""" % (xml_data)
data_comp_period = '\n\t\t<Declarant>\n\t\t\t<VATNumber xmlns="http://www.minfin.fgov.be/InputCommon">%(vatnum)s</VATNumber>\n\t\t\t<Name>%(company_name)s</Name>\n\t\t\t<Street>%(street)s</Street>\n\t\t\t<PostCode>%(post_code)s</PostCode>\n\t\t\t<City>%(city)s</City>\n\t\t\t<CountryCode>%(country)s</CountryCode>\n\t\t<EmailAddress>%(email)s</EmailAddress>\n\t\t<Phone>%(phone)s</Phone></Declarant>' % (xml_data)
if month_quarter.startswith('3'):
data_comp_period += '\n\t\t<Period>\n\t<Quarter>'+month_quarter+'</Quarter> \n\t<Year>'+year+'</Year></Period>'
elif month_quarter.startswith('0') and month_quarter.endswith('0'):
data_comp_period+= '\n\t\t<Period>%(period)s</Period>' % (xml_data)
else:
data_comp_period += '\n\t\t<Period>\n\t<Month>'+month_quarter+'</Month> \n\t<Year>'+year+'</Year></Period>'
data_clientinfo = ''
for client in xml_data['clientlist']:
data_clientinfo +='\n\t\t<ClientList SequenceNum="%(seq)s">\n\t\t\t<CompanyInfo>\n\t\t\t\t<VATNum>%(vatnum)s</VATNum>\n\t\t\t\t<Country>%(country)s</Country>\n\t\t\t</CompanyInfo>\n\t\t\t<Amount>%(amount)s</Amount>\n\t\t\t<Code>%(code)s</Code>\n\t\t</ClientList>' % (client)
data_clientinfo +='\n\t\t<IntraClient SequenceNumber="%(seq)s">\n\t\t\t<CompanyVATNumber issuedBy="%(country)s">%(vatnum)s</CompanyVATNumber>\n\t\t\t<Code>%(code)s</Code>\n\t\t\t<Amount>%(amount)s</Amount>\n\t\t\n\t\t<CorrectingPeriod></CorrectingPeriod></IntraClient>' % (client)
data_decl = '\n\t<DeclarantList SequenceNum="1" DeclarantNum="%(dnum)s" ClientNbr="%(clientnbr)s" AmountSum="%(amountsum)s" >' % (xml_data)
data_decl = '\n\t<IntraListing SequenceNumber="1" ClientsNbr="%(clientnbr)s" DeclarantReference="%(dnum)s" AmountSum="%(amountsum)s" >' % (xml_data)
data_file += data_head + data_decl + data_comp_period + data_clientinfo + '\n\t</DeclarantList>\n</VatIntra>'
data_file += data_head + data_decl + data_comp_period + data_clientinfo + '\n<FileAttachment></FileAttachment>\n<Comment></Comment>\n\t</IntraListing>\n</IntraConsignment>'
context['file_save'] = data_file
model_data_ids = mod_obj.search(cursor, user,[('model','=','ir.ui.view'),('name','=','view_vat_intra_save')], context=context)