blog image

In this part we will collect all basic concept related to odoo

1.Menu

    
    <!- change leads menu sequence -->
    <record id="crm.crm_menu_leads" model="ir.ui.menu">
        <field name="sequence">0</field>
    </record>
    
    <!-- Rename - Sales -> Opportunity -->
    <record id="crm.crm_menu_sales" model="ir.ui.menu">
        <field name="name">Opportunities</field>
    </record>

    <!--  Showing existing functionality to our menu section :currencies -->
    <menuitem
        id="menu_currencies"
        name="Currencies"
        parent="crm.crm_menu_config"
        action="base.action_currency_form"
        sequence="4" 
    />



    <!-- To show main menu -->
    <menuitem id="menu_ems" name="EMS" web_icon="school,static/description/ems.png" sequence="1"/>

    <!-- To create submenu -->
    <menuitem id="menu_configuration" name="Configurations" parent="menu_ems" sequence="13" 
       groups="group_school_administration" />

    <menuitem id="menu_academic_year_form" name="Academic Years" parent="menu_configuration" />
    <menuitem id="menu_academic_year_sub_form" name="Years" parent="menu_academic_year_form" 
     action="action_academic_year_form" />



    <!-- Hiding menus -->
    <menuitem id="crm.crm_lead_menu_my_activities" active="False" />
    <menuitem id="crm.res_partner_menu_customer" active="False" />
    <menuitem id="utm.menu_link_tracker_root" active="False" />
    <menuitem id="crm.crm_menu_report" active="False" />
    <menuitem id="crm.sales_team_menu_team_pipeline" active="False" />



    <!-- Hide Different Menus -->
    <!-- Contacts -->
    <record id="contacts.menu_contacts" model="ir.ui.menu">
        <field name="active">False</field>
    </record>

    <!-- Calendar -->
    <record id="calendar.mail_menu_calendar" model="ir.ui.menu">
        <field name="active">False</field>
    </record>

    <!-- Discuss -->
    <record id="mail.menu_root_discuss" model="ir.ui.menu">
        <field name="active">False</field>
    </record>

    <!-- CRM -->
    <record id="crm.crm_menu_root" model="ir.ui.menu">
        <field name="active">False</field>
    </record>

    <!-- Link Tracker -->
    <record id="utm.menu_link_tracker_root" model="ir.ui.menu">
        <field name="active">False</field>
    </record>
    
    <!-- Sales -->
    <record id="sale.sale_menu_root" model="ir.ui.menu">
        <field name="active">False</field>
    </record>

    <!-- Invoicing -->
    <record id="account.menu_finance" model="ir.ui.menu">
        <field name="active">False</field>
    </record>

 

2. button in odoo

in odoo basically there are two type of button

i. object type

when this type of button is clicked then python function is called and run the functionality written on it.

example: delete one2many data by object button

<header>
 <button string='Delete student' name='_delete_student' type='object' class='oe_highlight' attrs="{'invisible':[('status','=','rejected')]}"/>
</header>

#then in python file you need to define function as below

def _delete_student(self):
   for record in self:
       record.student_subject_ids=[(5,0,0)]
   return {
          "effect":{
                      "fadeout":"slow",
                      "type":"rainbow_man",
                      "message":"Record has been delected successfully"
                    }
           }

# here student_subject_ids is the one2many fields of the model

ii. action type

when button is clicked then new view or xml file is opened.

 

3. Statusbar 

To make the status bar first you need to make status field in model as selection fields as 

status=fields.selection([('draft','Draft'),('approved',"Approved"),("rejected","Rejected")],default="draft",string="Status",readonly=True)


#then in views file
<header>
<field name='status' widget='statusbar'/>
</header>

 

4.chatter in odoo

_inherit=['mail.thread','mail.activity.mixin'] 

# in model add,track_visibility='always' in model attribute



# in .xml file where you want to show chatter you can put below code 

<div class="oe_chatter">

   <field name="message_follower_ids" groups="base.group_user" widget='mail_followers'/>

   <field name='activity_ids' widget='mail_activity'/>

   <field name="message_ids" widget='mail_thread' />

</div>

 5. sum and average in tree view

<field name='salary' sum='sum of salary'/>
<field name='age' avg='average of age'/>

 

6. priority / rating in  odoo

how to convert selection field into rating start


1.define selection field in models as 

rating=fields.Selection([

('0','very low'),

('1','low')])

2.define fields in views as follow

<field name='rating' widget='priority'/>

 

7. Archive button in odoo

 how to make archive button to make record active or inactive

active=fields.Boolean(string='status',default='active')

# lets make some design for the button 

<div class='oe_button_box' name='button_box'>
<button class='oe_stat_button' type='object' name='toggle_active' icon='fa-archive' style='bg-color:lightgray;color:mediumpurple'>
<field name='active' widget='boolean_button' options="{'terminology':'archived'}"/>
</button>
</div>

 

8. how to replace input field by button 

btn_integer=fields.Integer(string="button integer")

# in views section
<fields name='btn_integer' widget='float_toggle' option="{'range':[0,1,2,3,4,5]}" style='width;300px'/>

 

9. how to disable any week day from calender in datetype field

options="{'datepicker':'daysOfWeekDisabled':[0,6]}"

here 0=saturday
6=sunday

 

10. important widget in odoo

<fields name='country_ids' widget='many2many_tags'/>

how to make m2o field clickable in trree view
<fields name='country_id' widget='many2onebutton'/>

remove create and open from many2one
<fields name='country_id' options="{'no_open':True,'no_create':True}"/>

how to make one2many field editable at buttom or top of tree view
<tree string="student" editable="buttom" decoration-info="status=='active'" decoration-muted="status=='inactive'"> </tree>

other color are as : danger,warning,muted,bf(for bold),success,



how to add "add a section" and "add a Note" option in tree view of one2manyffield
                                <tree string="Remarks" default_order="date desc" widget="section_and_note_one2many">
                                    <control>
                                        <create string="Add Remark" />
  <create string="Add a section" context="{'default_display_type':'line_section'}"/>
  <create string="Add note" context="{'default_display_type':'line_note'}"/>
                                    </control>
                                    <field name="description" />
                                    <field name="create_uid" string='Created By' />
                                    <field name="create_date" string='Created On' />
                                </tree>







how to drag and drop record in up and down in tree view by  handle widget

sequence=fields.Integer(string='seq')
then in views
add this field in top of the tree view as 
<fields name='sequence' widget='handle'/>
<fields name='name'/>

if you want in one2many fields as well you can do same as above

 

 

 


About author

author image

Amrit Panta

Python developer, content writer



3 Comments

Amanda Martines 5 days ago

Exercitation photo booth stumptown tote bag Banksy, elit small batch freegan sed. Craft beer elit seitan exercitation, photo booth et 8-bit kale chips proident chillwave deep v laborum. Aliquip veniam delectus, Marfa eiusmod Pinterest in do umami readymade swag. Selfies iPhone Kickstarter, drinking vinegar jean.

Reply

Baltej Singh 5 days ago

Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.

Reply

Marie Johnson 5 days ago

Kickstarter seitan retro. Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.

Reply

Leave a Reply

Scroll to Top