Odoo 16 Development Book

Map View

One of the views that Odoo support is map view it displays the record on the map. Its root element is <map>. Here is an example.

Don't forget to add 'depends': [web_map], in manifest

To do this, first we have to create a model.

from odoo import models , fields
class Book(models.Model):
    _name = 'odoo.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)

Now we can arrange the corresponding model's view and map view.

So first we can create an action for the model.

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id="odoo_book_action" model="ir.actions.act_window">
        <field name="name">Book</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">odoo.book</field>
        <field name="view_mode">tree,form</field>
    </record>

Now we can set the map view.

<record id="odoo_book_map" model="ir.ui.view">
        <field name="name">odoo.book</field>
        <field name="model">odoo.book</field>
        <field name="arch" type="xml">
            <map res_partner="author">
            </map>
        </field>
    </record>
<record id="odoo_book_action_map" model="ir.actions.act_window.view">
        <field name="sequence" eval="3"/>
        <field name="view_mode">map</field>
        <field name="view_id" ref="odoo_book_map"/>
        <field name="act_window_id" ref="odoo_book_action"/>
    </record>

After creating a record in this model, we can see the map view.

odoo Development
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