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.09k
    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 if unity else False
        _name = 'nursery'
       _columns = {
    Untitled 1
       'rent_duration_unity' : fields.many2one('product.uom',  string='Unity',
      _defaults = {
                     'rent_duration_unity' : default_duration_unity,

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

    <?xml version="1.0"?>
    <record id="view_nursery_form77" model="ir.ui.view">
                <field name="name"></field>
                <field name="model">feedback</field>
                <field name="arch" type="xml">
                    <form string="Feedback">
                            <field name="rent_duration_unity"/>
    <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>
        <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"/>


 0 Comment(s)

Sign In

Sign up using

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: