Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12.0][BR000275][MIG] Migrate website_baidu_map_multi from 8.0 to 12.0 #240

Open
wants to merge 8 commits into
base: 12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions website_baidu_map_multi/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:alt: License

==================================
Website Baidu Map (Multi location)
==================================

This module inherits from the website_baidu_map module. It allows you to display multiple addresses on the map.


Contributors
------------

* Liu Lixia <[email protected]>
* Ruter Lyu <[email protected]>


Maintainer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update to newest

----------

.. image:: https://www.elico-corp.com/logo.png
:alt: Elico Corp
:target: https://www.elico-corp.com

This module is maintained by Elico Corporation.

Elico Corporation offers consulting services to implement open source management software in SMEs, with a strong involvement in quality of service.

Our headquarters are located in Shanghai with branches in Hong Kong, ShenZhen and Singapore servicing customers from Greater China, Asia Pacific, Europe, Americas, etc...
1 change: 1 addition & 0 deletions website_baidu_map_multi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions website_baidu_map_multi/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 2016-2019 Elico Corp (https://www.elico-corp.com).
# License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Website Baidu Map Multi',
'version': '12.0.1.0.0',
'category': 'Hidden',
'depends': ['website_baidu_map'],
'author': 'Elico-Corp',
'support': 'Elico-Corp',
'license': 'LGPL-3',
'website': 'https://www.elico-corp.com',
'data': [
'views/company_shop_view.xml',
'security/ir.model.access.csv',
'views/templates.xml',
],
'installable': True,
'application': False
}
1 change: 1 addition & 0 deletions website_baidu_map_multi/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import company_shop
19 changes: 19 additions & 0 deletions website_baidu_map_multi/models/company_shop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 2016-2019 Elico Corp (https://www.elico-corp.com).
# License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models


class CompanyShop(models.Model):
_name = 'company.shop'

name = fields.Char('Name', required=True)
city = fields.Char('City', required=True)
address = fields.Char('Address', required=True)
company_id = fields.Many2one(comodel_name='res.company', string='Company')


class ResCompany(models.Model):
_inherit = 'res.company'

shop_ids = fields.One2many(
comodel_name='company.shop', inverse_name='company_id', string='shop')
2 changes: 2 additions & 0 deletions website_baidu_map_multi/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_company_shop,company_shop,website_baidu_map_multi.model_company_shop,website.group_website_designer,1,1,1,1
43 changes: 43 additions & 0 deletions website_baidu_map_multi/views/company_shop_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2018-2019 Shanghai Elico Limited.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
-->
<odoo>
<record id="view_company_form" model="ir.ui.view">
<field name="name">Company Shop</field>
<field name="model">res.company</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//page[last()]" position="after">
<page string="Shops">
<field name="shop_ids"/>
</page>
</xpath>
</data>
</field>
</record>

<record id="company_shop_action" model="ir.actions.act_window">
<field name="name">Company Shop</field>
<field name="res_model">company.shop</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
</record>

<record id="company_shop_view_tree" model="ir.ui.view">
<field name="name">Company Shop Tree</field>
<field name="model">company.shop</field>
<field name="arch" type="xml">
<tree editable="top">
<field name="name"/>
<field name="city"/>
<field name="address"/>
<field name="company_id" invisible="1"/>
</tree>
</field>
</record>

</odoo>
33 changes: 33 additions & 0 deletions website_baidu_map_multi/views/templates.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
© 2018-2019 Shanghai Elico Limited.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
-->
<odoo>
ruter-lyu marked this conversation as resolved.
Show resolved Hide resolved

<template id="baidu_map_muti" name="map_multi"
inherit_id="website.company_description">
<xpath expr="//div[@id='baidu_map']" position="replace">
<div id="baidu_map">
<script type="text/javascript">
var map = new BMap.Map("baidu_map");
var citys = [];
var myKeys = [];
<t t-foreach="res_company.shop_ids" t-as="shops">
citys.push('<t t-esc="shops.city"/>');
myKeys.push('<t t-esc="shops.address"/>');
</t>
for(var i=0; i&lt;myKeys.length; i++){
map.centerAndZoom(citys[i],11);
map.enableScrollWheelZoom();
var local = new BMap.LocalSearch(map, {
renderOptions:{map: map}
});
local.search(myKeys[i]);
}
</script>
</div>
</xpath>
</template>

</odoo>