[MiG] port from 19

This commit is contained in:
2026-08-24 12:42:06 +02:00
parent b8c3e95031
commit 5b874d250a
14 changed files with 393 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from .hooks import post_init_hook
+19
View File
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
{
'name': "Set as testserver Open2Bizz, when website is enabled",
'summary': """
Only to be used when installed as TEST env. Open2Bizz""",
'author': "Open2bizz",
'website': "http://www.open2bizz.tech",
'category': 'Tools',
'license': "AGPL-3",
'version': '16.0.1.0.0',
'depends': ['testserver_o2b','website'],
'data': [
'views/templates.xml',
],
'post_init_hook': 'post_init_hook',
}
+64
View File
@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
import logging
from odoo import api, fields, models, SUPERUSER_ID
_logger = logging.getLogger(__name__)
def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
model_website_page = env['ir.model'].search([
('model', '=', 'website.page')
])
test_view = env['ir.model.data']._xmlid_to_res_id(
'testserver_website_o2b.testserver_page_website'
)
if model_website_page:
for page in env['website.page'].search([]):
_logger.error("________Disable page %s", page.id)
page.write({
'is_published': False,
})
new_page = env['website.page'].create({
'name': "Testbeeld",
'url': "/testmodus",
'view_id': test_view,
'is_published': True,
})
for website in env['website'].search([]):
website.write({
'domain': False,
'homepage_url': new_page.url,
})
module_ecommerce = env['ir.module.module'].search([
('name', '=', 'website_sale')
])
if module_ecommerce and module_ecommerce.state == 'installed':
# Disable payment options
for payment_method in env['payment.method'].search([]):
payment_method.write({
'active': False,
})
_logger.error(
"________Disable payment method %s",
payment_method.id,
)
# Disable products
for product in env['product.template'].search([]):
product.write({
'website_published': False,
})
_logger.error(
"________Disable product %s",
product.id,
)
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

@@ -0,0 +1,18 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<body>
<div class="document" id="module-name">
<h1 class="title">Testservers when website</h1>
<p>
This module is ONLY for test environments In DC Open2Bizz
</p>
<p>
Module is developed by Open2Bizz. Bug reports: support@open2bizz.eu
</p>
<p>
<img src="https://www.open2bizz.tech/logo.png" style="max-height: 100px;">
</p>
</div>
</body>
</html>
@@ -0,0 +1,48 @@
<odoo>
<data>
<!-- Banner for web layout (website Odoo) -->
<template id="testserver_banner_website" name="TOP banner test front" inherit_id="website.layout">
<xpath expr="//body" position="before">
<div>
<span style="text-align: center;color: #FFFFFF;background-color: #006CFE;position: relative;display: block;font-size: 16px;">
***** This is a test environment *****
<a href="https://www.open2bizz.tech/helpdesk" target="_blank" style="color: #000000;">
See website to report issue's.
</a>
</span>
</div>
</xpath>
</template>
<!-- Replacement layout (website Odoo) -->
<template id="testserver_page_website" name="Website page front">
<t t-name="website.test-env">
<t t-call="website.layout">
<div id="wrap" class="oe_structure oe_empty">
<section class="s_banner parallax s_parallax_is_fixed pb96 o_colored_level pt40"
data-scroll-background-ratio="1"
data-snippet="s_banner" data-name="Banner" style="background-image: none;">
<span class="s_parallax_bg oe_img_bg o_bg_img_center"
style="background-image: url(&quot;https://hd-beamers.nl/wp-content/uploads/2014/05/Testbeeld-1280x720p_hd-ready.png&quot;); background-position: 50% 0px;"/>
<div class="o_we_bg_filter" style="background-image: linear-gradient(135deg, rgba(21, 25, 116, 0.71) 0%, rgba(226, 51, 255, 0.5) 100%);"/>
<div class="container">
<div class="row s_nb_column_fixed">
<div class="col-lg-6 jumbotron rounded o_cc o_cc1 pt32 pb32 o_colored_level" data-name="Box">
<h1><font style="font-size: 62px;" class="o_default_snippet_text">TEST</font><br/></h1>
<p class="lead o_default_snippet_text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<a class="mb-2 btn btn-primary" href="/web/login" data-bs-original-title="" title="">Login</a>
<br/>
<br/>
<a class="mb-2 btn btn-secondary" href="https://www.open2bizz.nl" data-bs-original-title="" title="">Open2Bizz</a>
</div>
</div>
</div>
</section>
</div>
</t>
</t>
</template>
</data>
</odoo>