forked from OCA/product-attribute
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost_init_hook.py
More file actions
20 lines (15 loc) · 741 Bytes
/
post_init_hook.py
File metadata and controls
20 lines (15 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import logging
from odoo import SUPERUSER_ID, api
_logger = logging.getLogger(__name__)
def initialize_attribute_is_favorite_field(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
for company in env["res.company"].with_context(active_test=False).search([]):
_logger.info("Configure is_favorite field for the company %s" % (company.name))
product_attributes = (
env["product.attribute"].sudo().with_company(company.id).search([])
)
product_attributes.write({"is_favorite": True})
product_attribute_values = (
env["product.attribute.value"].sudo().with_company(company.id).search([])
)
product_attribute_values.write({"is_favorite": True})