_check_vat_uniqueness optimization with browse

Registered by Juan Márquez on 2013-07-16

Optimize _check_vat_uniqueness code with "browse" and other thinks:

    def _check_vat_uniqueness(self, cr, uid, ids, context={}):
        ids = isinstance(ids, (int, long)) and [ids] or ids
        partner_obj = self.pool.get('res.partner')
        partner_brw = partner_obj.browse(cr,uid,ids,context=context)[0]
        current_vat = partner_brw.vat.upper().strip() or ''
        if not current_vat or not 'VE' in [a.country_id.code for a in partner_brw.address]:
            return True # Accept empty and foreign VAT's
        duplicates = partner_obj.search(cr, uid, [('vat', '=', current_vat),('id','!=',partner_brw.id)])
        return not duplicates

Blueprint information

Status:
Started
Approver:
None
Priority:
Low
Drafter:
None
Direction:
Needs approval
Assignee:
Juan Márquez
Definition:
New
Series goal:
None
Implementation:
Beta Available
Milestone target:
None
Started by
Juan Márquez on 2013-07-16

Whiteboard

pueden encontrar el código ya optimizado en:
l10n_ve_ fiscal_requirements/partner.py (revno: 711)

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.