Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Onchange of product and sets some values in openerp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 231
    Comment on it

    In product module use onchange function and sets some value and return dictionary of value in on_client_changed function to first inherit the product module class like as product.template class and then use this function in .py file in openerp use this function given below,

    def on_client_changed(self, cr, uid, ids, part, context=None):
            if not part:
    
                return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False,  'payment_term': False, 'fiscal_position_id': False}}
    
            part = self.pool.get('res.partner').browse(cr, uid, part, context=context)
            addr = self.pool.get('res.partner').address_get(cr, uid, [part.id], ['delivery', 'invoice', 'contact', 'order'])
            pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False
            payment_term = part.property_payment_term_id and part.property_payment_term_id.id or False
            fiscal_position_id = part.property_account_position_id and part.property_account_position_id.id or False
            dedicated_salesman = part.user_id and part.user_id.id or uid
            val = {
                'partner_invoice_id': addr['invoice'],
                'partner_shipping_id': addr['delivery'],
                'partner_order_id': addr['order'],
                'payment_term_id': payment_term,
                'fiscal_position_id': fiscal_position_id,
                'user_id': dedicated_salesman,
            }
            if pricelist:
                val['pricelist_id'] = pricelist
            return {'value': val}
    

 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: