mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-25 10:51:59 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -1,18 +1,33 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
||||
from odoo.tools.misc import str2bool
|
||||
|
||||
from . import const
|
||||
from . import controllers
|
||||
from . import models
|
||||
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})
|
||||
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)
|
||||
send_invoice_cron.active = bool(config)
|
||||
def _post_init_hook(env):
|
||||
_synchronize_crons(env)
|
||||
_setup_downpayment_account(env)
|
||||
|
||||
|
||||
def _synchronize_crons(env):
|
||||
for param, cron_xmlid in const.PARAM_CRON_MAPPING.items():
|
||||
if cron := env.ref(cron_xmlid, raise_if_not_found=False):
|
||||
cron.active = str2bool(env['ir.config_parameter'].get_param(param, 'False'))
|
||||
|
||||
|
||||
def _setup_downpayment_account(env):
|
||||
for company in env.companies:
|
||||
if not company.chart_template:
|
||||
continue
|
||||
|
||||
template_data = env['account.chart.template']._get_chart_template_data(company.chart_template).get('template_data')
|
||||
if template_data and template_data.get('downpayment_account_id'):
|
||||
property_downpayment_account = env['account.chart.template'].with_company(company).ref(template_data['downpayment_account_id'], raise_if_not_found=False)
|
||||
if property_downpayment_account:
|
||||
company.downpayment_account_id = property_downpayment_account
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue