Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Return the 1st UoM present into the Duration category in openerp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 189
    Comment on it

    First create fields rent_duration_unity in your own module then create class and use this rent_duration_unity fields which you created first in .py file, as shown in code given below.

     'rent_duration_unity' : fields.many2one('product.uom', string='Unity', 
                                     help='The duration unity, available choices depends of your company configuration.')
    

    Now use this function in relate to fields in your .py file in openerp, the function is given below

    def default_duration_unity(self, cr, uid, context=None):
    
            """
            Returns the 1st UoM present into the Duration category.
            """
            unity1 = self.pool['product.uom'].search(cr, uid, [])[1]
            unity = self.pool['product.uom'].browse(cr, uid, unity1)
            if not unity:
                _logger.warning("It seems that there isn't a reference unity in the 'Duration' UoM category. "
                                "Please check that the category exists, and there's a reference unity.")
    
            return unity.id if unity else False
    

 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: