~vauxoo/openerp-venezuela-localization/nhomar-rif_logger

« back to all changes in this revision

Viewing changes to l10n_ve_withholding_iva/partner.py

[MERGE] We created a wizard to allow update all parter information directly from SENIAT

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
        if xml_data.find('450')>=0:
104
104
            if not 'all_rif' in context:
105
105
                self._print_error(_('Vat Error !'),_('Invalid VAT!'))
 
106
            else:
 
107
                return True
106
108
 
107
109
        if xml_data.find('452')>=0:
108
110
            if not 'all_rif' in context:
109
111
                self._print_error(_('Vat Error !'),_('Unregistered VAT!'))
 
112
            else:
 
113
                return True
110
114
 
111
115
        if xml_data.find("404")>=0:
112
116
            if not 'all_rif' in context:
113
117
                self._print_error(_('No Connection !'),_("Could not connect! Check the URL "))
 
118
            else:
 
119
                return True
114
120
    
115
121
    def update_rif(self, cr, uid, ids, context={}):
116
122
        print 'entando update'
117
123
        for partner in self.browse(cr,uid,ids):
118
124
            url1=partner.company_id.url_seniat1_company+'%s'
119
125
            url2=partner.company_id.url_seniat2_company+'%s'
120
 
            xml_data = self._load_url(3,url1 %partner.vat[2:])
121
 
            self._eval_seniat_data(xml_data,context)
122
 
            print 'xml_data',xml_data
123
 
            dom = parseString(xml_data)
124
 
            self.write(cr,uid,partner.id,self._parse_dom(dom,partner.vat[2:],url2))
 
126
            print "URL1",url1
 
127
            print "URL2",url2
 
128
            if partner.vat:
 
129
                xml_data = self._load_url(3,url1 %partner.vat[2:])
 
130
                print self._eval_seniat_data(xml_data,context)
 
131
                if not self._eval_seniat_data(xml_data,context):
 
132
                    print "entro en el if"
 
133
                    print 'xml_data',xml_data
 
134
                    dom = parseString(xml_data)
 
135
                    self.write(cr,uid,partner.id,self._parse_dom(dom,partner.vat[2:],url2))
 
136
                else:
 
137
                    print "entro en el else"
 
138
                    return False
 
139
            else:
 
140
                if not 'all_rif' in context:
 
141
                    self._print_error(_('Vat Error !'),_('The field vat is empty'))
125
142
        return True
126
143
 
127
144
    def connect_seniat(self, cr, uid, ids, context={}, all_rif=False):
129
146
            ctx = context.copy()
130
147
            ctx.update({'all_rif': True})
131
148
        for partner in self.browse(cr,uid,ids):
132
 
            self. update_rif(cr, uid, [partner.id], context=ctx)
 
149
            self.update_rif(cr, uid, [partner.id], context=ctx)
133
150
 
134
151
        return True
135
152