forked from OCA/purchase-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhooks.py
More file actions
32 lines (29 loc) · 1018 Bytes
/
hooks.py
File metadata and controls
32 lines (29 loc) · 1018 Bytes
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
# Copyright 2019-2024 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging
_logger = logging.getLogger(__name__)
def post_init_hook(env):
"""Existing employees should be subscribed to the new subtype for all
existing purchase orders.
"""
_logger.info(
"Starting task to update internal followers for "
"existing purchase orders to assign the new subtype "
"Purchase Receptions."
)
users = env["res.users"].search([])
followers = env["mail.followers"].search(
[
("res_model", "=", "purchase.order"),
("partner_id", "in", users.mapped("partner_id").ids),
]
)
for follower in followers:
follower.subtype_ids += env.ref(
"purchase_reception_notify.mt_purchase_reception"
)
_logger.info(
"Finalized task to update internal followers for "
"existing purchase orders to assign the new subtype "
"Purchase Receptions."
)