[IMP] base, *: change the API of init hooks to pass env
This is mostly a cleaning/refactoring change.
The current API for init hooks (pre, post, uninstall) is to pass
`cr, registry`.
But the first thing which was done by most
post init and uninstall hooks was to create an env using
the cr passed
e.g.
`env = api.Environment(cr, SUPERUSER_ID, {})`
and the `registry` argument was unused in all these hooks,
completely.
By changing the API of hooks to pass `env` instead
of `cr, registry`, we gain in average two lines in every
hooks:
- the line creating the env `env = api.Environment(cr, SUPERUSER_ID, {})`
- the line importing `api` and `SUPERUSER_ID`
Therefore removing ~250 lines of repeated code lines accross odoo/odoo and
odoo/enterprise.
In addition to these lines removed,
it also ease the API of init hooks for Odoo developers,
who are used to that `env` and not so much how to create an `env`
from a cursor.
Part-of: odoo/odoo#108254
This commit is contained in:
@@ -9,7 +9,6 @@ from . import report
|
||||
from . import populate
|
||||
from . import tools
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
SYSCOHADA_LIST = ['BJ', 'BF', 'CM', 'CF', 'KM', 'CG', 'CI', 'GA', 'GN', 'GW', 'GQ', 'ML', 'NE', 'CD', 'SN', 'TD', 'TG']
|
||||
|
||||
@@ -59,7 +58,6 @@ def _auto_install_l10n(env):
|
||||
if module_ids:
|
||||
module_ids.sudo().button_install()
|
||||
|
||||
def _account_post_init(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _account_post_init(env):
|
||||
_auto_install_l10n(env)
|
||||
_set_fiscal_country(env)
|
||||
|
||||
@@ -26,12 +26,11 @@ def migrate_set_tags_and_taxes_updatable(cr, registry, module):
|
||||
if xml_record_ids:
|
||||
cr.execute("update ir_model_data set noupdate = 'f' where id in %s", (tuple(xml_record_ids),))
|
||||
|
||||
def preserve_existing_tags_on_taxes(cr, registry, module):
|
||||
def preserve_existing_tags_on_taxes(env, module):
|
||||
''' This is a utility function used to preserve existing previous tags during upgrade of the module.'''
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
xml_records = env['ir.model.data'].search([('model', '=', 'account.account.tag'), ('module', 'like', module)])
|
||||
if xml_records:
|
||||
cr.execute("update ir_model_data set noupdate = 't' where id in %s", [tuple(xml_records.ids)])
|
||||
env.cr.execute("update ir_model_data set noupdate = 't' where id in %s", [tuple(xml_records.ids)])
|
||||
|
||||
def update_taxes_from_templates(cr, chart_template_xmlid):
|
||||
def _create_tax_from_template(company, template, old_tax=None):
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, SUPERUSER_ID
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
||||
|
||||
def create_check_sequence_on_bank_journals(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def create_check_sequence_on_bank_journals(env):
|
||||
env['account.journal'].search([('type', '=', 'bank')])._create_check_sequence()
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
from . import models
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def _create_demo_config_param(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _create_demo_config_param(env):
|
||||
env['ir.config_parameter'].set_param('account_edi_proxy_client.demo', 'demo')
|
||||
|
||||
@@ -4,21 +4,17 @@ from . import controllers
|
||||
from . import models
|
||||
from . import wizards
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
def post_init_hook(env):
|
||||
""" Create `account.payment.method` records for the installed payment providers. """
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
PaymentProvider = env['payment.provider']
|
||||
installed_providers = PaymentProvider.search([('module_id.state', '=', 'installed')])
|
||||
for code in set(installed_providers.mapped('code')):
|
||||
PaymentProvider._setup_payment_method(code)
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
def uninstall_hook(env):
|
||||
""" Delete `account.payment.method` records created for the installed payment providers. """
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
installed_providers = env['payment.provider'].search([('module_id.state', '=', 'installed')])
|
||||
env['account.payment.method'].search([
|
||||
('code', 'in', installed_providers.mapped('code')),
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
|
||||
from . import models
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def _assign_default_nomeclature_id(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _assign_default_nomeclature_id(env):
|
||||
company_ids_without_default_nomenclature_id = env['res.company'].search([
|
||||
('nomenclature_id', '=', False)
|
||||
])
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
||||
from odoo import api, tools, SUPERUSER_ID
|
||||
from odoo import tools
|
||||
|
||||
|
||||
def _auto_install_apps(cr, registry):
|
||||
def _auto_install_apps(env):
|
||||
if not tools.config.get('default_productivity_apps', False):
|
||||
return
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
env['ir.module.module'].sudo().search([
|
||||
('name', 'in', [
|
||||
# Community
|
||||
|
||||
@@ -3,11 +3,8 @@
|
||||
|
||||
from . import models
|
||||
|
||||
from odoo.api import Environment, SUPERUSER_ID
|
||||
|
||||
|
||||
def _synchronize_cron(cr, registry):
|
||||
env = Environment(cr, SUPERUSER_ID, {'active_test': False})
|
||||
def _synchronize_cron(env):
|
||||
cron = env.ref('crm_iap_enrich.ir_cron_lead_enrichment')
|
||||
if cron:
|
||||
config = env['ir.config_parameter'].get_param('crm.iap.lead.enrich.setting', 'auto')
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
# -*- 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, {})
|
||||
def _install_hr_localization(env):
|
||||
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'),
|
||||
|
||||
@@ -3,12 +3,8 @@
|
||||
|
||||
from . import models
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
|
||||
def post_init_hook(env):
|
||||
email = env['ir.config_parameter'].get_param('hr_presence.hr_presence_control_email')
|
||||
ip = env['ir.config_parameter'].get_param('hr_presence.hr_presence_control_ip')
|
||||
|
||||
|
||||
@@ -7,14 +7,12 @@ from . import report
|
||||
from . import wizard
|
||||
from . import populate
|
||||
|
||||
from odoo import api, fields, SUPERUSER_ID, _
|
||||
from odoo import fields, _
|
||||
|
||||
from odoo.addons.project import _check_exists_collaborators_for_project_sharing
|
||||
|
||||
|
||||
def create_internal_project(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
|
||||
def create_internal_project(env):
|
||||
# allow_timesheets is set by default, but erased for existing projects at
|
||||
# installation, as there is no analytic account for them.
|
||||
env['project.project'].search([]).write({'allow_timesheets': True})
|
||||
@@ -34,8 +32,7 @@ def create_internal_project(cr, registry):
|
||||
|
||||
_check_exists_collaborators_for_project_sharing(env)
|
||||
|
||||
def _uninstall_hook(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _uninstall_hook(env):
|
||||
act_window = env.ref('project.open_view_project_all', raise_if_not_found=False)
|
||||
if act_window and act_window.domain and 'is_internal_project' in act_window.domain:
|
||||
act_window.domain = []
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
|
||||
from . import models
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def _validate_existing_work_entry(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _validate_existing_work_entry(env):
|
||||
env['hr.work.entry'].search([])._check_if_error()
|
||||
|
||||
@@ -6,7 +6,7 @@ from . import models
|
||||
from odoo.http import request
|
||||
|
||||
|
||||
def _post_init_hook(cr, registry):
|
||||
def _post_init_hook(env):
|
||||
if request:
|
||||
request.is_frontend = False
|
||||
request.is_frontend_multilang = False
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
from . import models
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_be.l10nbe_chart_template').process_coa_translations()
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_bg.l10n_bg_chart_template').process_coa_translations()
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_bo.bo_chart_template').process_coa_translations()
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
|
||||
# Copyright (C) 2010 Savoir-faire Linux (<https://www.savoirfairelinux.com>).
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
from . import models
|
||||
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_ca.ca_en_chart_template_en').process_coa_translations()
|
||||
|
||||
@@ -5,8 +5,6 @@ from . import models
|
||||
from . import report
|
||||
from . import wizard
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def load_translations(env):
|
||||
env.ref('l10n_ch.l10nch_chart_template').process_coa_translations()
|
||||
@@ -25,7 +23,6 @@ def init_settings(env):
|
||||
res_config_id.execute()
|
||||
|
||||
|
||||
def post_init(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def post_init(env):
|
||||
load_translations(env)
|
||||
init_settings(env)
|
||||
|
||||
@@ -5,8 +5,5 @@
|
||||
|
||||
from . import models
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_cn.l10n_chart_china_small_business').process_coa_translations()
|
||||
|
||||
@@ -8,9 +8,7 @@
|
||||
# Nhomar Hernandez (Vauxoo)
|
||||
# Humberto Ochoa (Vauxoo)
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
from . import models
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_co.l10n_co_chart_template_generic').process_coa_translations()
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
# or implied, of ClearCorp S.A..
|
||||
#
|
||||
##############################################################################
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_cr.account_chart_template_0').process_coa_translations()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_de_skr03.l10n_de_chart_template').process_coa_translations()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_de_skr04.l10n_chart_de_skr04').process_coa_translations()
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_dk.dk_chart_template').process_coa_translations()
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import models
|
||||
from . import demo
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_ec.l10n_ec_ifrs').process_coa_translations()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
from odoo import api, SUPERUSER_ID
|
||||
from . import models
|
||||
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_eg.egypt_chart_template_standard').process_coa_translations()
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import models
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def _l10n_es_edi_post_init(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _l10n_es_edi_post_init(env):
|
||||
companies = env['res.company'].search([('partner_id.country_id.code', '=', 'ES')])
|
||||
|
||||
all_chart_templates = companies.chart_template_id
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def l10n_eu_oss_post_init(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def l10n_eu_oss_post_init(env):
|
||||
env['res.company']._map_all_eu_companies_taxes()
|
||||
|
||||
def l10n_eu_oss_uninstall(cr, registry):
|
||||
cr.execute("DELETE FROM ir_model_data WHERE module = 'l10n_eu_oss' and model in ('account.tax.group', 'account.account');")
|
||||
def l10n_eu_oss_uninstall(env):
|
||||
env.cr.execute("DELETE FROM ir_model_data WHERE module = 'l10n_eu_oss' and model in ('account.tax.group', 'account.account');")
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from. import models
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_fi.fi_chart_template').process_coa_translations()
|
||||
|
||||
@@ -2,24 +2,20 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
# Copyright (c) 2008 JAILLET Simon - CrysaLEAD - www.crysalead.fr
|
||||
|
||||
from . import models
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_fr.l10n_fr_pcg_chart_template').process_coa_translations()
|
||||
|
||||
def _l10n_fr_post_init_hook(cr, registry):
|
||||
_preserve_tag_on_taxes(cr, registry)
|
||||
_setup_inalterability(cr, registry)
|
||||
def _l10n_fr_post_init_hook(env):
|
||||
_preserve_tag_on_taxes(env)
|
||||
_setup_inalterability(env)
|
||||
|
||||
def _preserve_tag_on_taxes(cr, registry):
|
||||
def _preserve_tag_on_taxes(env):
|
||||
from odoo.addons.account.models.chart_template import preserve_existing_tags_on_taxes
|
||||
preserve_existing_tags_on_taxes(cr, registry, 'l10n_fr')
|
||||
preserve_existing_tags_on_taxes(env, 'l10n_fr')
|
||||
|
||||
def _setup_inalterability(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _setup_inalterability(env):
|
||||
# enable ping for this module
|
||||
env['publisher_warranty.contract'].update_notification(cron_mode=True)
|
||||
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
|
||||
from . import models
|
||||
from . import report
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def _setup_inalterability(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _setup_inalterability(env):
|
||||
# enable ping for this module
|
||||
env['publisher_warranty.contract'].update_notification(cron_mode=True)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
cr.execute(
|
||||
def uninstall_hook(env):
|
||||
env.cr.execute(
|
||||
"DELETE FROM ir_model_data WHERE module = 'l10n_generic_coa'"
|
||||
)
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_hr.l10n_hr_chart_template').process_coa_translations()
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_hu.hungarian_chart_template').process_coa_translations()
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_id.l10n_id_chart').process_coa_translations()
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
from . import models
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
import logging
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@@ -42,6 +40,5 @@ def load_taxes(env):
|
||||
_logger.error("Can't load TCS and TDS account so account is not set in taxes of company: %s(%s).", company.name, company.id)
|
||||
|
||||
|
||||
def l10n_in_post_init(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def l10n_in_post_init(env):
|
||||
load_taxes(env)
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
|
||||
def load_translations(env):
|
||||
env.ref('l10n_it.l10n_it_chart_template_generic').process_coa_translations()
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
from . import models
|
||||
from . import tools
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def _l10n_it_edi_update_export_tax(env):
|
||||
chart_template = env.ref('l10n_it.l10n_it_chart_template_generic', raise_if_not_found=False)
|
||||
@@ -20,6 +18,5 @@ def _l10n_it_edi_update_export_tax(env):
|
||||
})
|
||||
|
||||
|
||||
def _l10n_it_edi_post_init(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _l10n_it_edi_post_init(env):
|
||||
_l10n_it_edi_update_export_tax(env)
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def _create_picking_seq(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _create_picking_seq(env):
|
||||
ptypes = env['stock.picking.type'].search([('code', '=', 'outgoing'), ('warehouse_id', '!=', False)])
|
||||
for ptype in ptypes:
|
||||
wh = ptype.warehouse_id
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
from . import models
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_kz.l10nkz_chart_template').process_coa_translations()
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import models
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def _set_default_identification_type(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _set_default_identification_type(env):
|
||||
env.cr.execute(
|
||||
"""
|
||||
UPDATE res_partner
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def load_translations(cr, registry):
|
||||
def load_translations(env):
|
||||
"""Load template translations."""
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
env.ref(
|
||||
'l10n_lt.account_chart_template_lithuania').process_coa_translations()
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
from . import models
|
||||
|
||||
def _post_init_hook(cr, registry):
|
||||
_preserve_tag_on_taxes(cr, registry)
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
|
||||
def _post_init_hook(env):
|
||||
_preserve_tag_on_taxes(env)
|
||||
env.ref('l10n_lu.lu_2011_chart_1').process_coa_translations()
|
||||
|
||||
def _preserve_tag_on_taxes(cr, registry):
|
||||
def _preserve_tag_on_taxes(env):
|
||||
from odoo.addons.account.models.chart_template import preserve_existing_tags_on_taxes
|
||||
preserve_existing_tags_on_taxes(cr, registry, 'l10n_lu')
|
||||
preserve_existing_tags_on_taxes(env, 'l10n_lu')
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_mx.mx_coa').process_coa_translations()
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref("l10n_my.l10n_my_chart_template").process_coa_translations()
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
# Copyright (C) 2016 Onestein (<http://www.onestein.eu>).
|
||||
|
||||
from . import models
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_nl.l10nnl_chart_template').process_coa_translations()
|
||||
|
||||
@@ -8,6 +8,6 @@ def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
env.ref('l10n_no.no_chart_template').process_coa_translations()
|
||||
|
||||
def _preserve_tag_on_taxes(cr, registry):
|
||||
def _preserve_tag_on_taxes(env):
|
||||
from odoo.addons.account.models.chart_template import preserve_existing_tags_on_taxes
|
||||
preserve_existing_tags_on_taxes(cr, registry, 'l10n_no')
|
||||
preserve_existing_tags_on_taxes(env, 'l10n_no')
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
# Copyright (c) 2011 Cubic ERP - Teradata SAC. (http://cubicerp.com).
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_pa.l10npa_chart_template').process_coa_translations()
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
from . import models
|
||||
from . import demo
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_pe.pe_chart_template').process_coa_translations()
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def _preserve_tag_on_taxes(cr, registry):
|
||||
def _preserve_tag_on_taxes(env):
|
||||
from odoo.addons.account.models.chart_template import preserve_existing_tags_on_taxes
|
||||
preserve_existing_tags_on_taxes(cr, registry, 'l10n_pl')
|
||||
preserve_existing_tags_on_taxes(env, 'l10n_pl')
|
||||
|
||||
|
||||
def load_translations(env):
|
||||
env.ref('l10n_pl.pl_chart_template').process_coa_translations()
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
_preserve_tag_on_taxes(cr, registry)
|
||||
def post_init_hook(env):
|
||||
_preserve_tag_on_taxes(env)
|
||||
load_translations(env)
|
||||
|
||||
@@ -8,10 +8,8 @@
|
||||
# Copyright (C) 2011 TOTAL PC SYSTEMS (http://www.erpsystems.ro).
|
||||
# Copyright (C) 2009 (<http://www.filsystem.ro>)
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
from . import models
|
||||
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_ro.ro_chart_template').process_coa_translations()
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
|
||||
def load_translations(env):
|
||||
env.ref('l10n_rs.l10n_rs_chart_template').process_coa_translations()
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
from . import models
|
||||
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_sa.sa_chart_template_standard').process_coa_translations()
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
# Copyright (C) 2014 Tech Receptives (<http://techreceptives.com>).
|
||||
from . import models
|
||||
|
||||
def _preserve_tag_on_taxes(cr, registry):
|
||||
def _preserve_tag_on_taxes(env):
|
||||
from odoo.addons.account.models.chart_template import preserve_existing_tags_on_taxes
|
||||
preserve_existing_tags_on_taxes(cr, registry, 'l10n_sg')
|
||||
preserve_existing_tags_on_taxes(env, 'l10n_sg')
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_si.gd_chart').process_coa_translations()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_sk.sk_chart_template').process_coa_translations()
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_syscohada.syscohada_chart_template').process_coa_translations()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
def _preserve_tag_on_taxes(cr, registry):
|
||||
def _preserve_tag_on_taxes(env):
|
||||
from odoo.addons.account.models.chart_template import preserve_existing_tags_on_taxes
|
||||
preserve_existing_tags_on_taxes(cr, registry, 'l10n_th')
|
||||
preserve_existing_tags_on_taxes(env, 'l10n_th')
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_tr.l10n_tr_chart_template').process_coa_translations()
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref("l10n_tw.l10n_tw_chart_template").process_coa_translations()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_uy.uy_chart_template').process_coa_translations()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def load_translations(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def load_translations(env):
|
||||
env.ref('l10n_ve.ve_chart_template_amd').process_coa_translations()
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
|
||||
# This module is Copyright (c) 2009-2013 General Solutions (http://gscom.vn) All Rights Reserved.
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def _post_init_hook(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _post_init_hook(env):
|
||||
env.ref('l10n_vn.vn_template').process_coa_translations()
|
||||
|
||||
@@ -6,14 +6,12 @@ from . import models
|
||||
from . import utils
|
||||
from . import wizard
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
import uuid
|
||||
|
||||
|
||||
def init_initiating_microsoft_uuid(cr, registry):
|
||||
def init_initiating_microsoft_uuid(env):
|
||||
""" Sets the company name as the default value for the initiating
|
||||
party name on all existing companies once the module is installed. """
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
config_parameter = env['ir.config_parameter'].sudo()
|
||||
microsoft_guid = config_parameter.get_param('microsoft_calendar.microsoft_guid', False)
|
||||
if not microsoft_guid:
|
||||
|
||||
+7
-11
@@ -7,33 +7,29 @@ from . import report
|
||||
from . import controller
|
||||
from . import populate
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def _pre_init_mrp(cr):
|
||||
def _pre_init_mrp(env):
|
||||
""" Allow installing MRP in databases with large stock.move table (>1M records)
|
||||
- Creating the computed+stored field stock_move.is_done and
|
||||
stock_move.unit_factor is terribly slow with the ORM and leads to "Out of
|
||||
Memory" crashes
|
||||
"""
|
||||
cr.execute("""ALTER TABLE "stock_move" ADD COLUMN "is_done" bool;""")
|
||||
cr.execute("""UPDATE stock_move
|
||||
env.cr.execute("""ALTER TABLE "stock_move" ADD COLUMN "is_done" bool;""")
|
||||
env.cr.execute("""UPDATE stock_move
|
||||
SET is_done=COALESCE(state in ('done', 'cancel'), FALSE);""")
|
||||
cr.execute("""ALTER TABLE "stock_move" ADD COLUMN "unit_factor" double precision;""")
|
||||
cr.execute("""UPDATE stock_move
|
||||
env.cr.execute("""ALTER TABLE "stock_move" ADD COLUMN "unit_factor" double precision;""")
|
||||
env.cr.execute("""UPDATE stock_move
|
||||
SET unit_factor=1;""")
|
||||
|
||||
def _create_warehouse_data(cr, registry):
|
||||
def _create_warehouse_data(env):
|
||||
""" This hook is used to add a default manufacture_pull_id, manufacture
|
||||
picking_type on every warehouse. It is necessary if the mrp module is
|
||||
installed after some warehouses were already created.
|
||||
"""
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
warehouse_ids = env['stock.warehouse'].search([('manufacture_pull_id', '=', False)])
|
||||
warehouse_ids.write({'manufacture_to_resupply': True})
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def uninstall_hook(env):
|
||||
warehouses = env["stock.warehouse"].search([])
|
||||
pbm_routes = warehouses.mapped("pbm_route_id")
|
||||
warehouses.write({"pbm_route_id": False})
|
||||
|
||||
@@ -5,11 +5,8 @@ from . import report
|
||||
from . import wizard
|
||||
from . import controllers
|
||||
|
||||
from odoo import SUPERUSER_ID, api
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def uninstall_hook(env):
|
||||
warehouses = env["stock.warehouse"].search([])
|
||||
subcontracting_routes = warehouses.mapped("subcontracting_route_id")
|
||||
warehouses.write({"subcontracting_route_id": False})
|
||||
|
||||
@@ -5,14 +5,10 @@ from . import models
|
||||
from . import utils
|
||||
from . import wizards
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def setup_provider(cr, registry, code):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def setup_provider(env, code):
|
||||
env['payment.provider']._setup_provider(code)
|
||||
|
||||
|
||||
def reset_payment_provider(cr, registry, code):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def reset_payment_provider(env, code):
|
||||
env['payment.provider']._remove_provider(code)
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import models
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'adyen')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'adyen')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'adyen')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'adyen')
|
||||
|
||||
@@ -9,16 +9,16 @@ from odoo.tools import config
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def pre_init_hook(cr):
|
||||
def pre_init_hook(env):
|
||||
if not any(config.get(key) for key in ('init', 'update')):
|
||||
raise UserError(
|
||||
"This module is deprecated and cannot be installed. "
|
||||
"Consider installing the Payment Provider: AsiaPay module instead.")
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'alipay')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'alipay')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'alipay')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'alipay')
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import models
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'aps')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'aps')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'aps')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'aps')
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import models
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'asiapay')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'asiapay')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'asiapay')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'asiapay')
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import models
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'authorize')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'authorize')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'authorize')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'authorize')
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import models
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'buckaroo')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'buckaroo')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'buckaroo')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'buckaroo')
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import models
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'custom')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'custom')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'custom')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'custom')
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import models
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'demo')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'demo')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'demo')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'demo')
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import models
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'flutterwave')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'flutterwave')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'flutterwave')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'flutterwave')
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import models
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'mercado_pago')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'mercado_pago')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'mercado_pago')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'mercado_pago')
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import models
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'mollie')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'mollie')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'mollie')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'mollie')
|
||||
|
||||
@@ -9,16 +9,16 @@ from odoo.tools import config
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def pre_init_hook(cr):
|
||||
def pre_init_hook(env):
|
||||
if not any(config.get(key) for key in ('init', 'update')):
|
||||
raise UserError(
|
||||
"This module is deprecated and cannot be installed. "
|
||||
"Consider installing the Payment Provider: Stripe module instead.")
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'ogone')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'ogone')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'ogone')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'ogone')
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import models
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'paypal')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'paypal')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'paypal')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'paypal')
|
||||
|
||||
@@ -9,16 +9,16 @@ from odoo.tools import config
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def pre_init_hook(cr):
|
||||
def pre_init_hook(env):
|
||||
if not any(config.get(key) for key in ('init', 'update')):
|
||||
raise UserError(
|
||||
"This module is deprecated and cannot be installed. "
|
||||
"Consider installing the Payment Provider: Mercado Pago module instead.")
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'payulatam')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'payulatam')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'payulatam')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'payulatam')
|
||||
|
||||
@@ -9,16 +9,16 @@ from odoo.tools import config
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def pre_init_hook(cr):
|
||||
def pre_init_hook(env):
|
||||
if not any(config.get(key) for key in ('init', 'update')):
|
||||
raise UserError(
|
||||
"This module is deprecated and cannot be installed. "
|
||||
"Consider installing the Payment Provider: Razorpay module instead.")
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'payumoney')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'payumoney')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'payumoney')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'payumoney')
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import models
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'razorpay')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'razorpay')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'razorpay')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'razorpay')
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import controllers
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'sips')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'sips')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'sips')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'sips')
|
||||
|
||||
@@ -6,9 +6,9 @@ from . import models
|
||||
from odoo.addons.payment import setup_provider, reset_payment_provider
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
setup_provider(cr, registry, 'stripe')
|
||||
def post_init_hook(env):
|
||||
setup_provider(env, 'stripe')
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'stripe')
|
||||
def uninstall_hook(env):
|
||||
reset_payment_provider(env, 'stripe')
|
||||
|
||||
@@ -3,11 +3,8 @@
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def uninstall_hook(env):
|
||||
ICP = env['ir.config_parameter']
|
||||
ICP.set_param('google.pse.id', False)
|
||||
ICP.set_param('google.custom_search.key', False)
|
||||
|
||||
@@ -7,8 +7,6 @@ from . import report
|
||||
from . import wizard
|
||||
from . import populate
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def _check_exists_collaborators_for_project_sharing(env):
|
||||
""" Check if it exists at least a collaborator in a shared project
|
||||
@@ -21,6 +19,5 @@ def _check_exists_collaborators_for_project_sharing(env):
|
||||
env['project.collaborator']._toggle_project_sharing_portal_rules(True)
|
||||
|
||||
|
||||
def _project_post_init(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _project_post_init(env):
|
||||
_check_exists_collaborators_for_project_sharing(env)
|
||||
|
||||
@@ -4,14 +4,11 @@
|
||||
from . import models
|
||||
|
||||
|
||||
def post_init(cr, registry):
|
||||
def post_init(env):
|
||||
""" Set the timesheet project and task on existing leave type. Do it in post_init to
|
||||
be sure the internal project/task of res.company are set. (Since timesheet_generate field
|
||||
is true by default, those 2 fields are required on the leave type).
|
||||
"""
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
for hr_leave_type in env['hr.leave.type'].search([('timesheet_generate', '=', True), ('timesheet_project_id', '=', False)]):
|
||||
company = hr_leave_type.company_id or env.company
|
||||
hr_leave_type.write({
|
||||
|
||||
@@ -6,14 +6,11 @@ from . import report
|
||||
from . import populate
|
||||
from . import wizard
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def _create_buy_rules(cr, registry):
|
||||
def _create_buy_rules(env):
|
||||
""" This hook is used to add a default buy_pull_id on every warehouse. It is
|
||||
necessary if the purchase_stock module is installed after some warehouses
|
||||
were already created.
|
||||
"""
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
warehouse_ids = env['stock.warehouse'].search([('buy_pull_id', '=', False)])
|
||||
warehouse_ids.write({'buy_to_resupply': True})
|
||||
|
||||
@@ -7,11 +7,8 @@ from . import report
|
||||
from . import wizard
|
||||
from . import populate
|
||||
|
||||
from odoo.api import Environment, SUPERUSER_ID
|
||||
|
||||
|
||||
def _synchronize_cron(cr, registry):
|
||||
env = Environment(cr, SUPERUSER_ID, {'active_test': False})
|
||||
def _synchronize_cron(env):
|
||||
send_invoice_cron = env.ref('sale.send_invoice_cron', raise_if_not_found=False)
|
||||
if send_invoice_cron:
|
||||
config = env['ir.config_parameter'].get_param('sale.automatic_invoice', False)
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def uninstall_hook(env):
|
||||
teams = env['crm.team'].search([('use_opportunities', '=', False)])
|
||||
teams.write({'use_opportunities': True})
|
||||
@@ -3,17 +3,15 @@
|
||||
|
||||
from . import models
|
||||
from . import controllers
|
||||
from odoo.api import Environment, SUPERUSER_ID
|
||||
from odoo.tools import column_exists, create_column
|
||||
|
||||
|
||||
def pre_init_hook(cr):
|
||||
def pre_init_hook(env):
|
||||
"""Do not compute the sale_order_template_id field on existing SOs."""
|
||||
if not column_exists(cr, "sale_order", "sale_order_template_id"):
|
||||
create_column(cr, "sale_order", "sale_order_template_id", "int4")
|
||||
if not column_exists(env.cr, "sale_order", "sale_order_template_id"):
|
||||
create_column(env.cr, "sale_order", "sale_order_template_id", "int4")
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
env = Environment(cr, SUPERUSER_ID, {})
|
||||
def uninstall_hook(env):
|
||||
res_ids = env['ir.model.data'].search([
|
||||
('model', '=', 'ir.ui.menu'),
|
||||
('module', '=', 'sale')
|
||||
@@ -21,8 +19,7 @@ def uninstall_hook(cr, registry):
|
||||
env['ir.ui.menu'].browse(res_ids).update({'active': False})
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
env = Environment(cr, SUPERUSER_ID, {})
|
||||
def post_init_hook(env):
|
||||
res_ids = env['ir.model.data'].search([
|
||||
('model', '=', 'ir.ui.menu'),
|
||||
('module', '=', 'sale'),
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from . import controllers
|
||||
from . import models
|
||||
|
||||
def _pre_init_sale_quotation_builder(cr):
|
||||
def _pre_init_sale_quotation_builder(env):
|
||||
""" Allow installing sale_quotation_builder in databases
|
||||
with large sale.order / sale.order.line tables.
|
||||
|
||||
@@ -14,19 +14,19 @@ def _pre_init_sale_quotation_builder(cr):
|
||||
By avoiding the computation of those fields,
|
||||
we reduce the installation time noticeably
|
||||
"""
|
||||
cr.execute("""
|
||||
env.cr.execute("""
|
||||
ALTER TABLE "sale_order"
|
||||
ADD COLUMN "website_description" text
|
||||
""")
|
||||
cr.execute("""
|
||||
env.cr.execute("""
|
||||
ALTER TABLE "sale_order_line"
|
||||
ADD COLUMN "website_description" text
|
||||
""")
|
||||
cr.execute("""
|
||||
env.cr.execute("""
|
||||
ALTER TABLE "sale_order_template_line"
|
||||
ADD COLUMN "website_description" text
|
||||
""")
|
||||
cr.execute("""
|
||||
env.cr.execute("""
|
||||
ALTER TABLE "sale_order_template_option"
|
||||
ADD COLUMN "website_description" text
|
||||
""")
|
||||
|
||||
@@ -5,15 +5,11 @@ from . import models
|
||||
from . import wizard
|
||||
from . import report
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
|
||||
def uninstall_hook(env):
|
||||
env.ref("account.account_analytic_line_rule_billing_user").write({'domain_force': "[(1, '=', 1)]"})
|
||||
|
||||
def _sale_timesheet_post_init(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _sale_timesheet_post_init(env):
|
||||
products = env['product.template'].search([('detailed_type', '=', 'service'), ('invoice_policy', '=', 'order'), ('service_type', '=', 'manual')])
|
||||
|
||||
for product in products:
|
||||
|
||||
@@ -8,19 +8,14 @@ from . import wizard
|
||||
from . import populate
|
||||
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
# TODO: Apply proper fix & remove in master
|
||||
def pre_init_hook(cr):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def pre_init_hook(env):
|
||||
env['ir.model.data'].search([
|
||||
('model', 'like', '%stock%'),
|
||||
('module', '=', 'stock')
|
||||
]).unlink()
|
||||
|
||||
def _assign_default_mail_template_picking_id(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _assign_default_mail_template_picking_id(env):
|
||||
company_ids_without_default_mail_template_id = env['res.company'].search([
|
||||
('stock_mail_confirmation_template_id', '=', False)
|
||||
])
|
||||
|
||||
@@ -5,13 +5,12 @@ from . import models
|
||||
from . import report
|
||||
from . import wizard
|
||||
|
||||
from odoo import api, SUPERUSER_ID, _, tools
|
||||
from odoo import _
|
||||
|
||||
def _configure_journals(cr, registry):
|
||||
|
||||
def _configure_journals(env):
|
||||
"""Setting journal and property field (if needed)"""
|
||||
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
|
||||
# if we already have a coa installed, create journal and set property field
|
||||
company_ids = env['res.company'].search([('chart_template_id', '!=', False)])
|
||||
todo_list = [
|
||||
|
||||
@@ -4,11 +4,8 @@
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def _assign_default_sms_template_picking_id(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def _assign_default_sms_template_picking_id(env):
|
||||
company_ids_without_default_sms_template_id = env['res.company'].search([
|
||||
('stock_sms_confirmation_template_id', '=', False)
|
||||
])
|
||||
|
||||
@@ -10,11 +10,10 @@ from odoo.http import request
|
||||
from functools import partial
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
def uninstall_hook(env):
|
||||
# Force remove ondelete='cascade' elements,
|
||||
# This might be prevented by another ondelete='restrict' field
|
||||
# TODO: This should be an Odoo generic fix, not a website specific one
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
website_domain = [('website_id', '!=', False)]
|
||||
env['ir.asset'].search(website_domain).unlink()
|
||||
env['ir.ui.view'].search(website_domain).with_context(active_test=False, _force_unlink=True).unlink()
|
||||
@@ -36,11 +35,10 @@ def uninstall_hook(cr, registry):
|
||||
('model', '=', 'res.config.settings'),
|
||||
]).unlink()
|
||||
|
||||
cr.postcommit.add(partial(rem_website_id_null, cr.dbname))
|
||||
env.cr.postcommit.add(partial(rem_website_id_null, env.cr.dbname))
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
def post_init_hook(env):
|
||||
env['ir.module.module'].update_theme_images()
|
||||
|
||||
if request:
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, SUPERUSER_ID, _
|
||||
from . import controllers
|
||||
from . import models
|
||||
from . import report
|
||||
|
||||
def _post_init_hook(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
|
||||
def _post_init_hook(env):
|
||||
terms_conditions = env['ir.config_parameter'].get_param('account.use_invoice_terms')
|
||||
if not terms_conditions:
|
||||
env['ir.config_parameter'].set_param('account.use_invoice_terms', True)
|
||||
@@ -15,11 +14,10 @@ def _post_init_hook(cr, registry):
|
||||
company.terms_type = 'html'
|
||||
env['website'].search([]).auth_signup_uninvited = 'b2c'
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
def uninstall_hook(env):
|
||||
''' Need to reenable the `product` pricelist multi-company rule that were
|
||||
disabled to be 'overridden' for multi-website purpose
|
||||
'''
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
pl_rule = env.ref('product.product_pricelist_comp_rule', raise_if_not_found=False)
|
||||
pl_item_rule = env.ref('product.product_pricelist_item_comp_rule', raise_if_not_found=False)
|
||||
multi_company_rules = pl_rule or env['ir.rule']
|
||||
|
||||
@@ -8,9 +8,6 @@ from . import report
|
||||
from . import wizard
|
||||
|
||||
|
||||
def post_init(cr, registry):
|
||||
def post_init(env):
|
||||
"""Rewrite ICP's to force groups"""
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
env['ir.config_parameter'].init(force=True)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user