import wizard import time import datetime import pooler import base64 form = """
""" fields = { 'fyear': {'string': 'Fiscal Year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True,}, 'mand_id':{'string':'MandataireId','type':'char','size':'30','required': True,}, 'limit_amount':{'string':'Limit Amount','type':'integer','required': True, }, 'test_xml': {'string':'Test XML file', 'type':'boolean', }, } msg_form = """ """ msg_fields = { 'msg': {'string':'File created', 'type':'text', 'size':'100','readonly':True}, 'file_save':{'string': 'Save File', 'type': 'binary', 'readonly': True,}, } class wizard_vat(wizard.interface): def _create_xml(self, cr, uid, data, context): datas=[] # now wizard will use user->company instead of directly company from res.company seq_controlref = pooler.get_pool(cr.dbname).get('ir.sequence').get(cr, uid,'controlref') seq_declarantnum = pooler.get_pool(cr.dbname).get('ir.sequence').get(cr, uid,'declarantnum') obj_cmpny = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid).company_id company_vat = obj_cmpny.partner_id.vat if not company_vat: #if not vat_company: raise wizard.except_wizard('Data Insufficient','No VAT Number Associated with Main Company!') cref = company_vat + seq_controlref dnum = cref + seq_declarantnum # obj_company=pooler.get_pool(cr.dbname).get('res.company').browse(cr,uid,1) # vat_company=obj_company.partner_id.vat #TODO: can be improved if we replace this test => add a new field on res_partner for cases when a partner has a number and is not subjected to the VAT... have to see if this situation could happen p_id_list=pooler.get_pool(cr.dbname).get('res.partner').search(cr,uid,[('vat','!=',False)]) if not p_id_list: raise wizard.except_wizard('Data Insufficient!','No partner has a VAT Number asociated with him.') obj_year=pooler.get_pool(cr.dbname).get('account.fiscalyear').browse(cr,uid,data['form']['fyear']) period="to_date('" + str(obj_year.date_start) + "','yyyy-mm-dd') and to_date('" + str(obj_year.date_stop) +"','yyyy-mm-dd')" street=zip_city=country='' if not obj_cmpny.partner_id.address: street=zip_city=country='' for ads in obj_cmpny.partner_id.address: if ads.type=='default': if ads.zip_id: zip_city=pooler.get_pool(cr.dbname).get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1] if ads.street: street=ads.street if ads.street2: street +=ads.street2 if ads.country_id: country=ads.country_id.code sender_date=time.strftime('%Y-%m-%d') data_file='\n