Files
odoo_source/addons/website_sale/__init__.py
T
William Braeckman 7e945db634 [FIX] website,website_sale: fix user sign up config
This commit aims to fix multiple issues with the "Customer Account"
parameter in the backend config.

 - Hide the parameter from general and sales settings if website is
   installed.
 - Properly compute the right value once website is installed, as it was
   not using the website's value.
 - Fix a traceback when clicking on "Default Access Rights".

TaskId-2825096

closes odoo/odoo#89806

X-original-commit: 8b162f507f881619061d61530cc03b4b4654c1fe
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
2022-04-27 12:16:28 +02:00

29 lines
1.2 KiB
Python

# -*- 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 wizard
from . import report
def _post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
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)
companies = env['res.company'].search([])
for company in companies:
company.terms_type = 'html'
env['website'].search([]).auth_signup_uninvited = 'b2c'
def uninstall_hook(cr, registry):
''' 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']
multi_company_rules += pl_item_rule or env['ir.rule']
multi_company_rules.write({'active': True})