[IMP] improved code of periodical vat declaration wizard.

bzr revid: tpa@tinyerp.com-20120913092814-eoxgnv0vzydpwfp3
This commit is contained in:
Turkesh Patel (Open ERP) 2012-09-13 14:58:14 +05:30
parent f29d02f20a
commit a931a9f298
3 changed files with 12 additions and 56 deletions

View File

@ -19,7 +19,6 @@
#
##############################################################################
import company
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,45 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv
class res_company(osv.osv):
_inherit = "res.company"
_description = 'Company'
def _get_default_ad(self, addresses):
name = email = phone = city = post_code = address = country_code = ""
for ads in addresses:
if ads.type == 'default':
city = ads.city or ""
post_code = ads.zip or ""
if ads.street:
address = ads.street or ""
if ads.street2:
address += " " + ads.street2
if ads.country_id:
country_code = ads.country_id and ads.country_id.code or ""
name = ads.name or ""
email = ads.email or ""
phone = ads.phone or ""
return name, email, phone, city, post_code, address, country_code
res_company()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -70,6 +70,7 @@ class l10n_be_vat_declaration(osv.osv_memory):
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_partner = self.pool.get('res.partner')
mod_obj = self.pool.get('ir.model.data')
if context is None:
@ -93,8 +94,9 @@ class l10n_be_vat_declaration(osv.osv_memory):
ctx['period_id'] = data['period_id'][0]
tax_info = obj_tax_code.read(cr, uid, tax_code_ids, ['code','sum_period'], context=ctx)
name = email = phone = address = post_code = city = country_code = ''
name, email, phone, city, post_code, address, country_code = self.pool.get('res.company')._get_default_ad(obj_company.partner_id)
default_address = obj_partner.address_get(cr, uid, [obj_company.partner_id.id])
default_address_id = default_address.get("default", obj_company.partner_id.id)
address_id= obj_partner.browse(cr, uid, default_address_id, context)
account_period = obj_acc_period.browse(cr, uid, data['period_id'][0], context=context)
issued_by = vat_no[:2]
@ -106,21 +108,21 @@ class l10n_be_vat_declaration(osv.osv_memory):
ending_month = account_period.date_stop[5:7]
quarter = str(((int(starting_month) - 1) / 3) + 1)
if not email:
if not address_id.email:
raise osv.except_osv(_('Insufficient Data!'),_('No email address associated with the company.'))
if not phone:
if not address_id.phone:
raise osv.except_osv(_('Insufficient Data!'),_('No phone associated with the company.'))
file_data = {
'issued_by': issued_by,
'vat_no': vat_no,
'only_vat': vat_no[2:],
'cmpny_name': obj_company.name,
'address': address,
'post_code': post_code,
'city': city,
'country_code': country_code,
'email': email,
'phone': phone.replace('.','').replace('/','').replace('(','').replace(')','').replace(' ',''),
'address': "%s %s"%(address_id.street or "",address_id.street2 or ""),
'post_code': address_id.zip or "",
'city': address_id.city or "",
'country_code': address_id.country_id and address_id.country_id.code or "",
'email': address_id.email or "",
'phone': address_id.phone.replace('.','').replace('/','').replace('(','').replace(')','').replace(' ',''),
'send_ref': send_ref,
'quarter': quarter,
'month': starting_month,