[FIX] hr: Fix localized hr module installation
closes odoo/odoo#95547 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, SUPERUSER_ID
|
||||
|
||||
from . import models
|
||||
from . import wizard
|
||||
from . import populate
|
||||
|
||||
|
||||
def _install_hr_localization(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
if any(c.partner_id.country_id.code == 'MX' for c in env['res.company'].search([])):
|
||||
l10n_mx = env['ir.module.module'].sudo().search([
|
||||
('name', '=', 'l10n_mx_hr'),
|
||||
('state', 'not in', ['installed', 'to install', 'to upgrade']),
|
||||
])
|
||||
if l10n_mx:
|
||||
l10n_mx.button_immediate_install()
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
],
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'post_init_hook': '_install_hr_localization',
|
||||
'assets': {
|
||||
'mail.assets_messaging': [
|
||||
'hr/static/src/models/*.js',
|
||||
|
||||
@@ -9,23 +9,3 @@ class Company(models.Model):
|
||||
|
||||
hr_presence_control_email_amount = fields.Integer(string="# emails to send")
|
||||
hr_presence_control_ip_list = fields.Char(string="Valid IP addresses")
|
||||
|
||||
def _install_hr_localizations(self):
|
||||
if any(c.partner_id.country_id.code == 'MX' for c in self):
|
||||
l10n_mx = self.env['ir.module.module'].sudo().search([
|
||||
('name', '=', 'l10n_mx_hr'),
|
||||
('state', 'not in', ['installed', 'to install', 'to upgrade']),
|
||||
])
|
||||
if l10n_mx:
|
||||
l10n_mx.button_immediate_install()
|
||||
|
||||
def create(self, vals_list):
|
||||
res = super().create(vals_list)
|
||||
res._install_hr_localizations()
|
||||
return res
|
||||
|
||||
def write(self, vals):
|
||||
res = super().write(vals)
|
||||
if 'country_id' in vals:
|
||||
self._install_hr_localizations()
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user