From 966f688c3c6f0101c3c8013d2ec703daf6f268a4 Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Wed, 18 Jan 2012 10:42:56 +0530 Subject: [PATCH 01/11] [IMP] improved and modified the Partner VAT Intra wizard of l10n_be module bzr revid: bde@tinyerp.com-20120118051256-wm9n4rp0ypmjcuiq --- addons/l10n_be/wizard/l10n_be_vat_intra.py | 59 ++++++++++++++-------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/addons/l10n_be/wizard/l10n_be_vat_intra.py b/addons/l10n_be/wizard/l10n_be_vat_intra.py index d61af532ce9..3c31de4d5bd 100644 --- a/addons/l10n_be/wizard/l10n_be_vat_intra.py +++ b/addons/l10n_be/wizard/l10n_be_vat_intra.py @@ -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 = """ - - - - %(company_vat)s - %(company_name)s - %(street)s - %(zip_city)s - %(country)s - - """ % (xml_data) - - data_comp_period = '\n\t\t\n\t\t\t%(vatnum)s\n\t\t\t%(company_name)s\n\t\t\t%(street)s\n\t\t\t%(zip_city)s\n\t\t\t%(country)s\n\t\t\n\t\t%(period)s' % (xml_data) + + %(company_name)s + %(mand_id)s""" % (xml_data) + + data_comp_period = '\n\t\t\n\t\t\t%(vatnum)s\n\t\t\t%(company_name)s\n\t\t\t%(street)s\n\t\t\t%(post_code)s\n\t\t\t%(city)s\n\t\t\t%(country)s\n\t\t%(email)s\n\t\t%(phone)s' % (xml_data) + if month_quarter.startswith('3'): + data_comp_period += '\n\t\t\n\t'+month_quarter+' \n\t'+year+'' + elif month_quarter.startswith('0') and month_quarter.endswith('0'): + data_comp_period+= '\n\t\t%(period)s' % (xml_data) + else: + data_comp_period += '\n\t\t\n\t'+month_quarter+' \n\t'+year+'' data_clientinfo = '' for client in xml_data['clientlist']: - data_clientinfo +='\n\t\t\n\t\t\t\n\t\t\t\t%(vatnum)s\n\t\t\t\t%(country)s\n\t\t\t\n\t\t\t%(amount)s\n\t\t\t%(code)s\n\t\t' % (client) + data_clientinfo +='\n\t\t\n\t\t\t%(vatnum)s\n\t\t\t%(code)s\n\t\t\t%(amount)s\n\t\t\n\t\t' % (client) - data_decl = '\n\t' % (xml_data) + data_decl = '\n\t' % (xml_data) - data_file += data_head + data_decl + data_comp_period + data_clientinfo + '\n\t\n' + data_file += data_head + data_decl + data_comp_period + data_clientinfo + '\n\n\n\t\n' context['file_save'] = data_file model_data_ids = mod_obj.search(cursor, user,[('model','=','ir.ui.view'),('name','=','view_vat_intra_save')], context=context) From c38b686d5ffeed7232c1477cbcaf518edee3ebf2 Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Wed, 18 Jan 2012 15:15:49 +0530 Subject: [PATCH 02/11] [IMP] removed unused attributes from IntraConsignment tag, added tag and improved the code bzr revid: bde@tinyerp.com-20120118094549-7brcez5af6g43oop --- addons/l10n_be/wizard/l10n_be_vat_intra.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/addons/l10n_be/wizard/l10n_be_vat_intra.py b/addons/l10n_be/wizard/l10n_be_vat_intra.py index 3c31de4d5bd..800535286ae 100644 --- a/addons/l10n_be/wizard/l10n_be_vat_intra.py +++ b/addons/l10n_be/wizard/l10n_be_vat_intra.py @@ -114,21 +114,13 @@ 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 = '' + email = data_cmpny.partner_id.email or '' + phone = data_cmpny.partner_id.phone or '' if addr.get('invoice',False): ads = obj_partner_add.browse(cr, uid, [addr['invoice']])[0] 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: @@ -210,11 +202,11 @@ class partner_vat_intra(osv.osv_memory): # Can't we do this by etree? data_head = """ - + %(company_name)s %(mand_id)s""" % (xml_data) - data_comp_period = '\n\t\t\n\t\t\t%(vatnum)s\n\t\t\t%(company_name)s\n\t\t\t%(street)s\n\t\t\t%(post_code)s\n\t\t\t%(city)s\n\t\t\t%(country)s\n\t\t%(email)s\n\t\t%(phone)s' % (xml_data) + data_comp_period = '\n\t\t\n\t\t\n\t\t\t%(vatnum)s\n\t\t\t%(company_name)s\n\t\t\t%(street)s\n\t\t\t%(post_code)s\n\t\t\t%(city)s\n\t\t\t%(country)s\n\t\t%(email)s\n\t\t%(phone)s' % (xml_data) if month_quarter.startswith('3'): data_comp_period += '\n\t\t\n\t'+month_quarter+' \n\t'+year+'' elif month_quarter.startswith('0') and month_quarter.endswith('0'): From 0d35811e7012a5ccca1d28982c822243f5045458 Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Tue, 24 Jan 2012 15:24:21 +0530 Subject: [PATCH 03/11] [IMP] improved the Partner VAT Intra Wizard bzr revid: bde@tinyerp.com-20120124095421-fe920muq7xnppmxu --- addons/l10n_be/wizard/l10n_be_vat_intra.py | 44 ++++++++++++++----- .../l10n_be/wizard/l10n_be_vat_intra_view.xml | 7 ++- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/addons/l10n_be/wizard/l10n_be_vat_intra.py b/addons/l10n_be/wizard/l10n_be_vat_intra.py index 800535286ae..57fb2994d7d 100644 --- a/addons/l10n_be/wizard/l10n_be_vat_intra.py +++ b/addons/l10n_be/wizard/l10n_be_vat_intra.py @@ -52,19 +52,23 @@ class partner_vat_intra(osv.osv_memory): ''' ), 'period_ids': fields.many2many('account.period', 'account_period_rel', 'acc_id', 'period_id', 'Period (s)', help = 'Select here the period(s) you want to include in your intracom declaration'), - 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', domain=[('parent_id', '=', False)]), + 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', domain=[('parent_id', '=', False)], help="Keep empty to use the user's company"), 'test_xml': fields.boolean('Test XML file', help="Sets the XML output as test file"), 'mand_id' : fields.char('MandataireId', size=14, required=True, help="This identifies the representative of the sending company. This is a string of 14 characters"), 'msg': fields.text('File created', size=14, readonly=True), 'no_vat': fields.text('Partner With No VAT', size=14, readonly=True, help="The Partner whose VAT number is not defined they doesn't include in XML File."), 'file_save' : fields.binary('Save File', readonly=True), 'country_ids': fields.many2many('res.country', 'vat_country_rel', 'vat_id', 'country_id', 'European Countries'), + 'comments': fields.text('Comments'), + 'identification_type': fields.selection([('tin','TIN'), ('nvat','NVAT'), ('other','Other')], 'Identification Type', required=True), + 'other': fields.char('Other Qlf', size=16, help="Description of Identification Type"), } _defaults = { 'country_ids': _get_europe_country, 'file_save': _get_xml_data, 'name': 'vat_Intra.xml', + 'identification_type': 'tin', } def _get_datas(self, cr, uid, ids, context=None): @@ -86,17 +90,21 @@ class partner_vat_intra(osv.osv_memory): seq = amount_sum = 0 wiz_data = self.browse(cr, uid, ids[0], context=context) + type = wiz_data.identification_type or '' + other = wiz_data.other or '' + comments = wiz_data.comments if wiz_data.tax_code_id: data_cmpny = wiz_data.tax_code_id.company_id else: data_cmpny = obj_user.browse(cr, uid, uid, context=context).company_id - + # Get Company vat company_vat = data_cmpny.partner_id.vat if not company_vat: raise osv.except_osv(_('Data Insufficient'),_('No VAT Number Associated with Main Company!')) company_vat = company_vat.replace(' ','').upper() + issued_by = company_vat[:2] if len(wiz_data.period_code) != 6: raise osv.except_osv(_('Wrong Period Code'), _('The period code you entered is not valid.')) @@ -144,7 +152,12 @@ class partner_vat_intra(osv.osv_memory): 'email': email, 'phone': phone, 'period': wiz_data.period_code, - 'clientlist': [] + 'clientlist': [], + 'comments': comments, + 'type': type.upper(), + 'other': other, + 'issued_by': issued_by, + 'company_registry': data_cmpny.company_registry, }) codes = ('44', '46L', '46T') @@ -202,25 +215,34 @@ class partner_vat_intra(osv.osv_memory): # Can't we do this by etree? data_head = """ - - %(company_name)s + + + %(company_registry)s + %(company_name)s + %(street)s + %(post_code)s + %(city)s + %(country)s + %(email)s + %(phone)s + %(mand_id)s""" % (xml_data) - data_comp_period = '\n\t\t\n\t\t\n\t\t\t%(vatnum)s\n\t\t\t%(company_name)s\n\t\t\t%(street)s\n\t\t\t%(post_code)s\n\t\t\t%(city)s\n\t\t\t%(country)s\n\t\t%(email)s\n\t\t%(phone)s' % (xml_data) + data_comp_period = '\n\t\t\n\t\t\n\t\t\t%(vatnum)s\n\t\t\t%(company_name)s\n\t\t\t%(street)s\n\t\t\t%(post_code)s\n\t\t\t%(city)s\n\t\t\t%(country)s\n\t\t\t%(email)s\n\t\t\t%(phone)s\n\t\t' % (xml_data) if month_quarter.startswith('3'): - data_comp_period += '\n\t\t\n\t'+month_quarter+' \n\t'+year+'' + data_comp_period += '\n\t\t\n\t\t\t'+month_quarter+' \n\t\t\t'+year+'\n\t\t' elif month_quarter.startswith('0') and month_quarter.endswith('0'): data_comp_period+= '\n\t\t%(period)s' % (xml_data) else: - data_comp_period += '\n\t\t\n\t'+month_quarter+' \n\t'+year+'' + data_comp_period += '\n\t\t\n\t\t\t'+month_quarter+' \n\t\t\t'+year+'\n\t\t' data_clientinfo = '' for client in xml_data['clientlist']: - data_clientinfo +='\n\t\t\n\t\t\t%(vatnum)s\n\t\t\t%(code)s\n\t\t\t%(amount)s\n\t\t\n\t\t' % (client) + data_clientinfo +='\n\t\t\n\t\t\t%(vatnum)s\n\t\t\t%(code)s\n\t\t\t%(amount)s\n\t\t\t\n\t\t\t\t \n\t\t\t\t\n\t\t\t\n\t\t' % (client) - data_decl = '\n\t' % (xml_data) + data_decl = '\n\t' % (xml_data) - data_file += data_head + data_decl + data_comp_period + data_clientinfo + '\n\n\n\t\n' + data_file += data_head + data_decl + data_comp_period + data_clientinfo + '\n\t\t \n\t\t%(comments)s\n\t\n' % (xml_data) context['file_save'] = data_file model_data_ids = mod_obj.search(cursor, user,[('model','=','ir.ui.view'),('name','=','view_vat_intra_save')], context=context) diff --git a/addons/l10n_be/wizard/l10n_be_vat_intra_view.xml b/addons/l10n_be/wizard/l10n_be_vat_intra_view.xml index a6d251983d3..b770c00b265 100644 --- a/addons/l10n_be/wizard/l10n_be_vat_intra_view.xml +++ b/addons/l10n_be/wizard/l10n_be_vat_intra_view.xml @@ -23,12 +23,17 @@ - + + + +