I've custom module with
"depends": ["sale_management", "mrp"],
i want to make like when my custom module install it will automatically enable "Multi-Step Routes" in settings, how to configure such a setting by python code.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
I've custom module with
"depends": ["sale_management", "mrp"],
i want to make like when my custom module install it will automatically enable "Multi-Step Routes" in settings, how to configure such a setting by python code.
Hi,
Please refer to the code below:
__Manifest__.py
"depends": ["sale_management", "mrp"],
"post_init_hook": "post_init_hook",
__init__.py
def post_init_hook(env):
"""
Post-init hook to automatically enable the 'Multi-Step Routes' setting
by activating the corresponding user group.
This function is called after the module installation. It ensures that
the 'stock.group_stock_multi_locations' group (which enables the Multi-Step
Routes feature in Inventory settings) is added to the implied groups of
'base.group_user', making it active for all internal users by default.
:param env: Odoo environment with superuser privileges.
"""
group = env.ref('stock.group_stock_multi_locations')
base_group_user = env.ref('base.group_user')
if group not in base_group_user.implied_ids:
base_group_user.write({'implied_ids': [(4, group.id)]})
Hope it helps.
You can inherit res.config.settings model and create all the configurations you want.
Example:
class ResConfigSettings(models.TransientModel):
_inherit = ["res.config.settings"]
max_product_registries = fields.Integer(
string="Max Product Registries",
default=5000,
help="Maximum number of product registries to be updated at once.",
config_parameter="your_module.max_product_registries",
)
product_manufacturer_update = fields.Boolean(
string="Auto-Update Product Manufacturer",
default=True,
help="Choose if the products need to be updated with the manufacturer information automatically with the cron action.",
config_parameter="your_module.product_manufacturer_update",
)
i want to enable "Multi-Step Routes" which was already define in stock module
Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!
RekisteröidyAiheeseen liittyviä artikkeleita | Vastaukset | Näkymät | Toimenpide | |
---|---|---|---|---|
|
0
helmik. 25
|
899 | ||
|
1
toukok. 25
|
922 | ||
|
1
huhtik. 25
|
648 | ||
|
0
huhtik. 25
|
629 | ||
|
1
maalisk. 25
|
844 |