Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to retrun partner delivery address in OpenERP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 272
    Comment on it

    In OpenERP first create delivery address in delivery form and then we need to define a partner for the brand of the product and also dedicated_delivery_address stand for the case a new type of address. In stock form move all the delivery address to stock move form and return the partner delivery address.

    Use this function given below

    def return_address(self, cr, uid, ids, field_names, arg, context=None):
    
            result ={}
            address_obj = self.pool.get('res.partner.address')
            for supplier_info in self.browse(cr, uid, ids, context=context):
                result[supplier_info.id] = {}
                address_id = False
                return_partner = supplier_info.warranty_return_partner
                if return_partner:
                    if return_partner == 'supplier':
                        partner_id = supplier_info.name.id
                    elif return_partner == 'brand':
                        if not supplier_info.product_id.product_brand_id.partner_id:
                            raise osv.except_osv(_('Error !'), _('You need to define a partner for the brand of the product !'))
                        partner_id = supplier_info.product_id.product_brand_id.partner_id.id
                    else:
                        partner_id = supplier_info.company_id.partner_id.id
                    address_id = address_obj.search(cr, uid, [('partner_id', '=', partner_id), ('type', 'like', 'dedicated_delivery')], context=context)
                    if not address_id:
                        address_id = address_obj.search(cr, uid, [('partner_id','=', partner_id), ('type','like','delivery')], context=context)
                        if not address_id:
                            address_id = address_obj.search(cr, uid, [('partner_id', '=', partner_id), ('type', 'like', 'default')], context=context)
                    if not address_id:
                        raise osv.except_osv(_('Error !'), _('No address define for the %s!') % return_partner)
                    result[supplier_info.id] = address_id[0]
            return result
    

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: