-
-
Notifications
You must be signed in to change notification settings - Fork 966
Expand file tree
/
Copy pathhooks.py
More file actions
33 lines (29 loc) · 1.11 KB
/
hooks.py
File metadata and controls
33 lines (29 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Copyright 2015 Alexis de Lattre <alexis.delattre@akretion.com>
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
logger = logging.getLogger(__name__)
def set_default_map_settings(env):
"""Method called as post-install script
The default method on the field can't be used, because it would be executed
before loading map_website_data.xml, so it would not be able to set a
value"""
user_model = env["res.users"]
users = user_model.search([("context_map_website_id", "=", False)])
logger.info("Updating user settings for maps...")
users.write(
{
"context_map_website_id": user_model._default_map_website().id,
"context_route_map_website_id": (
user_model._default_route_map_website().id
),
}
)
# Update the starting partner this way that is faster
env.cr.execute(
"""
UPDATE res_users
SET context_route_start_partner_id = partner_id
WHERE context_route_start_partner_id IS NULL;
"""
)