Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create function to returns value of product name, unit price based on event in OpenERP?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 275
    Comment on it

    In OpenERP first you have to create the product and price of the product and then relate both price and product to the event form and return the value of the product and validate it to database like as in param self and param cr. Param self means that the object pointer and param cr means the current row of the database cursor and param uid means the current user’s ID for security checks.

    Use this function show in given below

    def onchangevent(self, cr, uid, ids, event_id, partner_invoice_id):
        
            context = {}
            if not event_id:
                return {'value': {'unit_price': False, 'event_product': False}}
    
            event_obj = self.pool.get('event.event')
            prod_obj = self.pool.get('product.product')
            res_obj = self.pool.get('res.partner')
    
            data_event =  event_obj.browse(cr, uid, event_id)
            res = {'value': {'unit_price': False,
                             'event_product': False,
                             'user_id': False,
                             'date': data_event.date_begin,
                             'date_deadline': data_event.date_end,
                             'description': data_event.note,
                             'name': data_event.name,
                             'section_id': data_event.section_id and data_event.section_id.id or False,
                            }}
            if data_event.user_id.id:
                res['value'].update({'user_id': data_event.user_id.id})
            if data_event.product_id:
                pricelist_id = data_event.pricelist_id and data_event.pricelist_id.id or False
                if partner_invoice_id:
                    partner = res_obj.browse(cr, uid, partner_invoice_id, context=context)
                    pricelist_id = pricelist_id or partner.property_product_pricelist.id
                unit_price = prod_obj._product_price(cr, uid, [data_event.product_id.id], False, False, {'pricelist': pricelist_id})[data_event.product_id.id]
                if not unit_price:
                    unit_price = data_event.unit_price
                res['value'].update({'unit_price': unit_price, 'event_product': data_event.product_id.name})
            return res
    

     

 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: