Chapter 6 - Odoo 15 Development Book

Map view

As we already said that, Odoo supports several views. such as tree view, form view, list view, Kanban view, pivot view, calendar view, activity view etc. Map view is able to display the record on map. Its root element is <map>.

In this view, we get information on the location of partners. It contains rows and columns. This is an enterprise feature.

Let’s create a map view:

'depends': [web_map],

created a model book.

class Book(models.Model):
   _name = 'book'
   _inherit = ['mail.thread', 'mail.activity.mixin']
   display_name = fields.Char(string='Name', required=True)
   author = fields.Many2one('res.partner', 'Author', required=True)
   sl_no = fields.Char('Sl No', required=True)

Created an action for this model

<record id="action_Book" model="ir.actions.act_window">
  <field name="name">Book</field>
  <field name="type">ir.actions.act_window</field>
  <field name="res_model">book</field>
  <field name="view_mode">tree,form,map</field>
</record>

This is the map view of this model

<record id="book_map" model="ir.ui.view">
  <field name="name">book.map</field>
      <field name="model">book</field>
      <field name="arch" type="xml">
<map res_partner="author" default_order="sl_no" routing="true" hide_name="true">
              <field name="author" string="Customer Name"/>
          </map>
      </field>
</record>
odoo-crm

It contains following attributes

res_partner:

many2one field for res.partners.

default_order:

If a field is provided, the view overrides the model’s default order. The field must be part of the model on which the view is applied, not from res.partner.

routing

If routing is true, it displays routes between records.

hide_name:

Hide the name from the pin’s popup.

hide_title:

Hide the title from the pin’s popup.

hide_address:

Hide the address from the pin’s popup.

panel_title:

Used to display as the title of the pin list.

In this we discussed different types of views like list view, form view, Kanban view, activity view etc.

whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message