Skip to content

Commit

Permalink
[MIG] website_product_configurator: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SirAionTech committed Jan 18, 2024
1 parent b348921 commit 82e37f9
Show file tree
Hide file tree
Showing 19 changed files with 309 additions and 466 deletions.
1 change: 0 additions & 1 deletion website_product_configurator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from . import models
from . import controllers
from . import tests
12 changes: 10 additions & 2 deletions website_product_configurator/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Website Product Configurator",
"version": "14.0.1.2.0",
"version": "16.0.1.0.0",
"summary": """Configure products in e-shop""",
"author": "Pledra, Odoo Community Association (OCA)",
"license": "AGPL-3",
Expand All @@ -16,11 +16,19 @@
"data/ir_config_parameter_data.xml",
"data/config_form_templates.xml",
"data/cron.xml",
"views/assets.xml",
"views/product_view.xml",
"views/templates.xml",
"views/res_config_settings_view.xml",
],
"assets": {
"web.assets_frontend": [
"website_product_configurator/static/src/js/config_form.js",
"website_product_configurator/static/src/js/website_sale.esm.js",
"website_product_configurator/static/src/js/website_config_tour.js",
"website_product_configurator/static/src/scss/config_form.scss",
"website_product_configurator/static/src/scss/tooltip.scss",
],
},
"demo": ["demo/product_template_demo.xml"],
"images": ["static/description/cover.png"],
"application": True,
Expand Down
7 changes: 5 additions & 2 deletions website_product_configurator/controllers/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import logging

from odoo import http, models
from odoo.exceptions import UserError, ValidationError
Expand All @@ -8,6 +9,8 @@
from odoo.addons.http_routing.models.ir_http import slug
from odoo.addons.website_sale.controllers.main import WebsiteSale

_logger = logging.getLogger(__name__)


def get_pricelist():
sale_order = request.env.context.get("sale_order")
Expand Down Expand Up @@ -467,8 +470,8 @@ def save_configuration(
valid = config_session_id.sudo().validate_configuration()
if valid:
check_next_step = False
except Exception:
pass
except Exception as exc:
_logger.debug(exc, exc_info=True)
if check_next_step:
result = self.set_config_next_step(
config_session_id=config_session_id,
Expand Down
142 changes: 90 additions & 52 deletions website_product_configurator/data/config_form_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@

<!-- Base view for website configuration body -->
<template id="product_configurator" name="Product Configuration Interface">
<xpath expr="." position="inside">
<t t-call="website.layout">
<div itemscope="itemscope" itemtype="http://schema.org/Product" id="wrap">

<section
id="product_configurator"
class="container py-2 product_configurator"
>
id="product_configurator"
class="container py-2 product_configurator"
>
<div class="row">
<div class="col-lg-12">
<t t-call="website_product_configurator.config_header" />
Expand All @@ -34,24 +33,24 @@
<div class="row">
<div class="col-lg-12">
<form
id="product_config_form"
class="form-horizontal"
method="post"
enctype="multipart/form-data"
>
id="product_config_form"
class="form-horizontal"
method="post"
enctype="multipart/form-data"
>
<input
type="hidden"
name="csrf_token"
t-att-value="request.csrf_token()"
/>
type="hidden"
name="csrf_token"
t-att-value="request.csrf_token()"
/>
<div class="row">
<div class="col-lg-12">
<div class="config_weight">
<span><b>Weight: </b></span>
<span
class="config_product_weight"
t-esc="('{0:,.%sf}' % (weight_prec)).format(cfg_session.weight)"
/>
class="config_product_weight"
t-esc="('{0:,.%sf}' % (weight_prec)).format(cfg_session.weight)"
/>
<span>kg</span>
</div>
<div class="config_price">
Expand All @@ -60,10 +59,10 @@
<!-- <span class="config_product_price" t-esc="cfg_session.price" t-options="{'widget': 'monetary', 'display_currency': product_tmpl.currency_id}"/> -->
<!-- Bizzappdev start code -->
<span
class="config_product_price"
t-esc="cfg_session.price"
t-options="{'widget': 'monetary', 'display_currency': website.get_current_pricelist().currency_id}"
/>
class="config_product_price"
t-esc="cfg_session.price"
t-options="{'widget': 'monetary', 'display_currency': website.get_current_pricelist().currency_id}"
/>
<!-- Bizzappdev end code -->

</div>
Expand All @@ -84,8 +83,8 @@
<div class="row">
<div class="col-lg-12">
<t
t-call="website_product_configurator.config_footer"
/>
t-call="website_product_configurator.config_footer"
/>
</div>
</div>
</form>
Expand All @@ -94,7 +93,6 @@
</section>
</div>
</t>
</xpath>
</template>

<template id="config_footer" name="Product Configuration Footer">
Expand Down Expand Up @@ -220,7 +218,8 @@
>
<a
t-att-class="'nav-link' + (cfg_step_line.id == active_step.id and ' active' or '')"
data-toggle="tab"
data-bs-toggle="tab"
t-attf-data-bs-target="#cfg_step_{{cfg_step_line.id}}"
role="tab"
t-attf-href="#cfg_step_{{cfg_step_line.id}}"
t-esc="cfg_step_line.config_step_id.name"
Expand Down Expand Up @@ -398,7 +397,7 @@
<t t-foreach="cfg_step_attribute_line_ids" t-as="line">
<t
t-set="custom_value"
t-value="custom_value_ids.filtered(lambda x, line=line: x.attribute_id == line.attribute_id)"
t-value="custom_value_ids.filtered(lambda x: x.attribute_id == line.attribute_id)"
/>
<t
t-set="available_val"
Expand Down Expand Up @@ -491,7 +490,7 @@
<t t-foreach="cfg_step_attribute_line_ids" t-as="line">
<t
t-set="custom_value"
t-value="custom_value_ids.filtered(lambda x, line=line: x.attribute_id == line.attribute_id)"
t-value="custom_value_ids.filtered(lambda x: x.attribute_id == line.attribute_id)"
/>
<t
t-set="available_val"
Expand Down Expand Up @@ -617,7 +616,7 @@
<t t-set="curr_pl" t-value="website.get_current_pricelist()" />
<t
t-set="price"
t-value="product_variant.with_context(pricelist=curr_pl.id).price"
t-value="product_variant.with_context(pricelist=curr_pl.id)._get_contextual_price()"
/>
<b
class="oe_price"
Expand Down Expand Up @@ -652,6 +651,7 @@
t-attf-class="container py-2 oe_website_sale #{'discount' if combination_info['has_discounted_price'] else ''}"
id="product_detail"
t-att-data-view-track="view_track and '1' or '0'"
t-att-data-product-tracking-info="json.dumps(request.env['product.template'].get_google_analytics_data(combination_info))"
>
<div class="row">
<div class="col-md-4">
Expand All @@ -675,9 +675,20 @@
</ol>
</div>
</div>
<div class="row">
<div
class="row"
id="product_detail_main"
data-name="Product Page"
t-att-data-image_width="website.product_page_image_width"
t-att-data-image_layout="website.product_page_image_layout"
>
<div class="col-md-6 col-xl-8">
<t t-call="website_sale.shop_product_carousel" />
<t t-call="website_sale.shop_product_carousel">
<t
t-set="product_images"
t-value="product_variant._get_images() if product_variant else product._get_images()"
/>
</t>
</div>
<div class="col-md-6 col-xl-4" id="product_details">
<h1 itemprop="name" t-field="product.name">Product Name</h1>
Expand All @@ -696,7 +707,7 @@
name="csrf_token"
t-att-value="request.csrf_token()"
/>
<div class="js_product js_main_product">
<div class="js_product js_main_product main_product">
<t t-placeholder="select">
<input
type="hidden"
Expand Down Expand Up @@ -732,6 +743,13 @@
t-field="val.attribute_id.name"
/>:
<span t-field="val.value" />
<input
type="hidden"
class="variant_custom_value"
t-att-data-custom_product_template_attribute_value_id="val.attribute_id.id"
t-att-data-attribute_value_name="val.attribute_id.name"
t-att-value="val.value"
/>
<t
t-foreach="val.attachment_ids"
t-as="attachment"
Expand All @@ -748,17 +766,50 @@
</ul>
</div>
</t>
<div
class="d-none oe_unchanged_value_ids"
t-att-data-unchanged_value_ids="product_variant.product_template_attribute_value_ids.ids"
/>
<t
t-call="website_product_configurator.product_price"
/>
<!-- <p t-if="True" class="css_not_available_msg alert alert-warning">This combination does not exist.</p> -->
<a
role="button"
id="add_to_cart"
class="btn btn-primary btn-lg mt16 js_check_product a-submit d-block d-sm-inline-block"
href="#"
><i class="fa fa-shopping-cart" /> Add to Cart</a>
<div id="product_option_block" />
<ul
class="d-none js_add_cart_variants mb-0"
t-att-data-attribute_exclusions="{'exclusions: []'}"
/>
<div
id="o_wsale_cta_wrapper"
class="d-flex flex-wrap align-items-center"
>
<t t-set="hasQuantities" t-value="false" />
<t t-set="hasBuyNow" t-value="false" />
<t
t-set="ctaSizeBig"
t-value="not hasQuantities or not hasBuyNow"
/>

<div
id="add_to_cart_wrap"
t-attf-class="{{'d-none' if combination_info['prevent_zero_price_sale'] else 'd-inline-flex'}} align-items-center mb-2 me-auto"
>
<a
data-animation-selector=".o_wsale_product_images"
role="button"
id="add_to_cart"
t-attf-class="btn btn-primary js_check_product a-submit flex-grow-1 #{'btn-lg' if ctaSizeBig else ''}"
href="#"
>
<i class="fa fa-shopping-cart me-2" />
<span
style="font-weight: bold"
>ADD TO CART</span>
</a>
</div>
<div
id="product_option_block"
class="d-flex flex-wrap w-100"
/>
</div>
</div>
</form>
<p
Expand Down Expand Up @@ -872,19 +923,6 @@
</xpath>
</template>

<template
id="recently_viewed_products_product_cfg"
inherit_id="website_product_configurator.cfg_product"
active="True"
customize_show="True"
name="Recently Viewed Products"
priority="16"
>
<xpath expr="//div[@t-field='product.website_description']" position="after">
<t t-call="website_sale.s_products_recently_viewed" />
</xpath>
</template>

<template
id="product_comment_cfg"
inherit_id="website_product_configurator.cfg_product"
Expand Down Expand Up @@ -930,7 +968,7 @@
</div>
<input
type="text"
class="form-control quantity"
class="form-control quantity text-center"
data-min="1"
name="add_qty"
t-att-value="add_qty or 1"
Expand Down
19 changes: 7 additions & 12 deletions website_product_configurator/data/ir_config_parameter_data.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<record
id="default_configuration_step_website_view_id"
model="ir.config_parameter"
>
<field
name="key"
>product_configurator.default_configuration_step_website_view_id</field>
<field name="value">website_product_configurator.config_form_select</field>
</record>
</data>
<odoo noupdate="1">
<record id="default_configuration_step_website_view_id" model="ir.config_parameter">
<field
name="key"
>product_configurator.default_configuration_step_website_view_id</field>
<field name="value">website_product_configurator.config_form_select</field>
</record>
</odoo>
2 changes: 0 additions & 2 deletions website_product_configurator/demo/product_template_demo.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>

<record id="product_configurator.bmw_2_series" model="product.template">
<field name="website_published">True</field>
</record>

</data>
</odoo>
1 change: 1 addition & 0 deletions website_product_configurator/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import product_config
from . import product_template
from . import res_config_settings
from . import sale_order
2 changes: 1 addition & 1 deletion website_product_configurator/models/product_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ProductConfigStepLine(models.Model):
def get_website_template(self):
"""Return the external id of the qweb template linked to this step"""
if self.website_tmpl_id:
xml_id_dict = self.website_tmpl_id.get_xml_id()
xml_id_dict = self.website_tmpl_id.get_external_id()
view_id = xml_id_dict.get(self.website_tmpl_id.id)
else:
view_id = self.env[
Expand Down
Loading

0 comments on commit 82e37f9

Please sign in to comment.