Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to set default Unit of Measure Categories(UOM) in odoo-9

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.07k
    Comment on it

    In odoo-9 we create functional fields and validate to function and set also set to default value of Unit of Measure Categories(UOM) in selected form.

    Use this step show in given below

    Step1- First create fields in your own module in .py file, show in given below

    class nursery(models.Model):
    
     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, [])[16]
            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
    
        _name = 'nursery'
       _columns = {
        
    Untitled 1
       'rent_duration_unity' : fields.many2one('product.uom',  string='Unity',
    required=True, 
        
         }
    
      _defaults = {
                     'rent_duration_unity' : default_duration_unity,
                     }
    nursery()
    

    Step2- Then we create view in .xml file in your own module show in given below

    <?xml version="1.0"?>
    <openerp>
    <data>
    
    <record id="view_nursery_form77" model="ir.ui.view">
                <field name="name">view.feedback.form</field>
                <field name="model">feedback</field>
                <field name="arch" type="xml">
                    <form string="Feedback">
                        <group>
                            <field name="rent_duration_unity"/>
                        </group>
                    </form>
                </field>
            </record>
    
    <record id="action_nursery33" model="ir.actions.act_window">
                <field name="name">Feedback</field>
                <field name="type">ir.actions.act_window</field>
                <field name="res_model">feedback</field>
                <field name="view_mode">tree,form</field>
            </record>
    
    
        <menuitem name="nursery" id="menu_student"/>
        <menuitem name="nursery" id="menu_nursery_item" parent="menu_student" action="action_nursery"/>
       <menuitem name="nursery create" id="menu_nursery_item" parent="menu_student" action="action_nursery33"/>
    
    </data>
    </openerp>
      

     

 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: