You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
2.8 KiB
121 lines
2.8 KiB
import logging
|
|
|
|
from odoo.api import Environment, SUPERUSER_ID
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
# def pre_init_hook(cr, registry):
|
|
# env = Environment(cr, SUPERUSER_ID, {})
|
|
# _logger.info("Pre init hook")
|
|
|
|
|
|
def post_init_hook(cr, registry):
|
|
# Source : https://en.wikipedia.org/wiki/Age_of_majority (2024-05-29)
|
|
env = Environment(cr, SUPERUSER_ID, {})
|
|
env["res.country"].search([("code", "in", ("ID", "YE"))]).write(
|
|
{
|
|
"majority_age": 15,
|
|
}
|
|
)
|
|
env["res.country"].search([("code", "in", ("KH", "CU", "MM", "VN"))]).write(
|
|
{
|
|
"majority_age": 16,
|
|
}
|
|
)
|
|
env["res.country"].search([("code", "in", ("KP", "TL"))]).write(
|
|
{
|
|
"majority_age": 17,
|
|
}
|
|
)
|
|
env["res.country"].search([("code", "in", ("DZ", "KR"))]).write(
|
|
{
|
|
"majority_age": 19,
|
|
}
|
|
)
|
|
env["res.country.state"].search(
|
|
[
|
|
"|",
|
|
"&",
|
|
("country_id.code", "=", "CA"),
|
|
(
|
|
"code",
|
|
"in",
|
|
(
|
|
"BC",
|
|
"NB",
|
|
"NL",
|
|
"NS",
|
|
"NT",
|
|
"NU",
|
|
"YT",
|
|
),
|
|
),
|
|
"&",
|
|
("country_id.code", "=", "US"),
|
|
(
|
|
"code",
|
|
"in",
|
|
(
|
|
"AL",
|
|
"NE",
|
|
),
|
|
),
|
|
]
|
|
).write(
|
|
{
|
|
"majority_age": 19,
|
|
"same_country_age": False,
|
|
}
|
|
)
|
|
env["res.country"].search([("code", "in", ("NZ", "TH"))]).write(
|
|
{
|
|
"majority_age": 20,
|
|
}
|
|
)
|
|
env["res.country"].search(
|
|
[
|
|
(
|
|
"code",
|
|
"in",
|
|
(
|
|
"CM",
|
|
"TD",
|
|
"CI",
|
|
"SZ",
|
|
"GA",
|
|
"GD",
|
|
"HN",
|
|
"KW",
|
|
"LS",
|
|
"MG",
|
|
"NI",
|
|
"NE",
|
|
"PR",
|
|
"WS",
|
|
"AE",
|
|
"ZM",
|
|
),
|
|
)
|
|
]
|
|
).write(
|
|
{
|
|
"majority_age": 21,
|
|
}
|
|
)
|
|
env["res.country.state"].search(
|
|
[
|
|
("country_id.code", "=", "US"),
|
|
("code", "=", "MS"),
|
|
]
|
|
).write(
|
|
{
|
|
"majority_age": 21,
|
|
}
|
|
)
|
|
_logger.info("\n#####\nPost init hook for contacts majority passed...\n#####\n")
|
|
|
|
|
|
# def uninstall_hook(cr, registry):
|
|
# env = Environment(cr, SUPERUSER_ID, {})
|
|
# _logger.info("Uninstall hook")
|