Browse Source

Nov 13 : [FIX] Bug Fixed 'call_for_price_website'

pull/295/head
AjmalCybro 2 years ago
parent
commit
df44242391
  1. 4
      call_for_price_website/README.rst
  2. 1
      call_for_price_website/__manifest__.py
  3. 3
      call_for_price_website/static/src/js/create_call_form.js
  4. 25
      call_for_price_website/static/src/js/variant_mixin.js
  5. 3
      call_for_price_website/views/call_for_price_views.xml
  6. 76
      call_for_price_website/views/shop_hide_call_price_template.xml
  7. 260
      call_for_price_website/views/website_product_template.xml

4
call_for_price_website/README.rst

@ -16,7 +16,9 @@ Company
Credits
-------
Developers: Raneesha M K @cybrosys, Muhsina V @cybrosys, Contact: odoo@cybrosys.com
Developers: Raneesha M K @cybrosys,
Muhsina V @cybrosys, Contact: odoo@cybrosys.com,
Farhana Jahan PT @cybrosys, Contact: odoo@cybrosys.com
Contacts
--------

1
call_for_price_website/__manifest__.py

@ -39,6 +39,7 @@
'views/compare_hide_price_template.xml',
'views/call_for_price_views.xml',
'views/product_product_views.xml',
'views/website_product_template.xml'
],
'assets': {
'web.assets_frontend': [

3
call_for_price_website/static/src/js/create_call_form.js

@ -116,7 +116,6 @@ odoo.define('call_for_price_website.create_call_form', function(require) {
this.$el.find('#quantity').val('');
this.$el.find('#message').val('');
},
});
return publicWidget.registry.CallForPrice;
});
});

25
call_for_price_website/static/src/js/variant_mixin.js

@ -8,9 +8,10 @@ odoo.define('call_for_price_website.CustomVariantMixin', function(require) {
// Import the VariantMixin from website_sale module
var VariantMixin = require('website_sale.VariantMixin');
// Store a reference to the original onChangeCombination function
const originalOnChangeCombination = VariantMixin._onChangeCombination;
const oldOnChangeCombination = VariantMixin._onChangeCombination;
// Override the onChangeCombination function to implement custom behavior
VariantMixin._onChangeCombination = function(ev, $parent, combination) {
const result = oldOnChangeCombination.apply(this, arguments);
const $pricePerUom = $parent.find(".o_base_unit_price:first .oe_currency_value");
if ($pricePerUom) {
if (combination.is_combination_possible !== false && combination.base_unit_price != 0) {
@ -36,25 +37,31 @@ odoo.define('call_for_price_website.CustomVariantMixin', function(require) {
const quantity = $parent.find('.css_quantity');
const product_unavailable = $parent.find('#product_unavailable');
const price_call_div = $parent.find('#price_call_hide');
if (combination.prevent_zero_price_sale) {
productPrice.removeClass('d-inline-block').addClass('d-none');
quantity.removeClass('d-inline-flex').addClass('d-none');
addToCart.removeClass('d-inline-flex').addClass('d-none');
contactUsButton.removeClass('d-none').addClass('d-flex');
product_unavailable.removeClass('d-none').addClass('d-flex')
} else if (combination.price_call) {
productPrice.removeClass('d-inline-block').addClass('d-none');
product_unavailable.removeClass('d-none').addClass('d-flex');
this.$el.find('.product_price_visible').removeClass('d-none').addClass('d-block');
this.$el.find('.product_price').remove();
}
if (combination.price_call) {
quantity.removeClass('d-inline-flex').addClass('d-none');
addToCart.removeClass('d-inline-flex').addClass('d-none');
contactUsButton.removeClass('d-none').addClass('d-flex');
price_call_div.removeClass('d-none').addClass('d-flex');
this.$el.find('#contact_us_wrapper').remove();
this.$el.find('#add_to_cart').removeClass('d-block').addClass('d-none');
this.$el.find('.product_price').removeClass('d-inline-block').addClass('d-none');
this.$el.find('#price_of_product').removeClass('d-block').addClass('d-none');
this.$el.find('#price_of_product').removeClass('d-block').addClass('d-none');
this.$el.find('.js_add_cart_json').removeClass('d-block').addClass('d-none');
this.$el.find('.quantity').removeClass('d-block').addClass('d-none');
} else {
this.$el.find('.css_quantity').removeClass('d-block').addClass('d-none');
this.$el.find('.product_price_visible').removeClass('d-block').addClass('d-none');
this.$el.find('.product_price').remove();
}
else {
productPrice.removeClass('d-none').addClass('d-inline-block');
quantity.removeClass('d-none').addClass('d-inline-flex');
addToCart.removeClass('d-none').addClass('d-inline-flex');
@ -66,8 +73,8 @@ odoo.define('call_for_price_website.CustomVariantMixin', function(require) {
this.$el.find('#price_of_product').removeClass('d-none').addClass('d-block');
this.$el.find('.js_add_cart_json').removeClass('d-none').addClass('d-block');
this.$el.find('.quantity').removeClass('d-none').addClass('d-block');
this.$el.find('.product_price_visible').removeClass('d-none').addClass('d-block');
}
// Call the original onChangeCombination function
originalOnChangeCombination.apply(this, [ev, $parent, combination]);
return result
};
});

3
call_for_price_website/views/call_for_price_views.xml

@ -51,9 +51,8 @@
<field name="res_model">call.price</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="call_price_menu" name="Call For Price"
parent="website_sale.menu_orders"
groups="sales_team.group_sale_salesman"
action="call_price_action"/>
</odoo>
</odoo>

76
call_for_price_website/views/shop_hide_call_price_template.xml

@ -42,82 +42,6 @@
<t t-set="display_detail" t-valuef="false"/>
</xpath>
</template>
<!-- Template for product price display -->
<template id="product_price" inherit_id="website_sale.product_price">
<xpath expr="//div[@itemprop='offers']" position="replace">
<div itemprop="offers" itemscope="itemscope"
itemtype="http://schema.org/Offer"
t-attf-class="product_price mt-2 mb-3 {{'d-none' if combination_info['prevent_zero_price_sale'] else 'd-inline-block'}}">
<h3 class="css_editable_mode_hidden" id="price_of_product">
<span class="oe_price" style="white-space: nowrap;"
t-esc="combination_info['price']"
t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
<span itemprop="price" style="display:none;"
t-esc="combination_info['price']"/>
<span itemprop="priceCurrency" style="display:none;"
t-esc="website.currency_id.name"/>
<span t-attf-class="text-danger oe_default_price ms-1 h5 {{'' if combination_info['has_discounted_price'] else 'd-none'}}"
style="text-decoration: line-through; white-space: nowrap;"
t-esc="combination_info['list_price']"
t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"
itemprop="listPrice"
/>
<t t-esc="product_id"/>
<t t-if="is_view_active('website_sale.tax_indication')"
t-call="website_sale.tax_indication"/>
<del t-if="product.compare_list_price">
<bdi dir="inherit">
<span t-field="product.compare_list_price"
groups="website_sale.group_product_price_comparison"
t-options='{"widget": "monetary",
"display_currency": product.currency_id,
}'/>
</bdi>
</del>
</h3>
<h3 id="price_of_products"
class="css_non_editable_mode_hidden decimal_precision"
t-att-data-precision="str(website.currency_id.decimal_places)"
style="display:none">
<span t-field="product.list_price"
t-options='{"widget": "monetary",
"display_currency": product.currency_id,
}'/>
<t t-if="is_view_active('website_sale.tax_indication')"
t-call="website_sale.tax_indication"/>
<del t-if="product.compare_list_price">
<bdi dir="inherit">
<span t-field="product.compare_list_price"
groups="website_sale.group_product_price_comparison"
t-options='{"widget": "monetary",
"display_currency": product.currency_id,
}'/>
</bdi>
</del>
</h3>
</div>
<div id="product_unavailable"
t-attf-class="{{'d-flex' if combination_info['prevent_zero_price_sale'] else 'd-none'}}">
<h3 class="fst-italic"
t-field="website.prevent_zero_price_sale_text"/>
</div>
<div id="price_call_hide" style="display:none">
<div>
<div class="alert alert-success" id="alert_message"
style="display:none">
Thank you for information, we will get back to you
asap.
</div>
<a role="button" class="btn btn-primary"
href="#call_for_price"
data-bs-toggle="modal"
id="button_call_for_price">
Call for Price
</a>
</div>
</div>
</xpath>
</template>
<!-- Template for 'Call for Price' modal -->
<template id="shop_product_hide_price" inherit_id="website_sale.product">
<xpath expr="//div[@id='o_product_terms_and_share']"

260
call_for_price_website/views/website_product_template.xml

@ -0,0 +1,260 @@
<odoo>
<template id="product_call" inherit_id="website_sale.product">
<xpath expr="//section[@id='product_detail']" position="replace">
<section t-attf-class="container py-4 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 align-items-center">
<div class="col-lg-6 d-flex align-items-center">
<div class="d-flex justify-content-between w-100">
<t t-call="website_sale.search">
<t t-set="search" t-value="False"/>
<t t-set="_form_classes" t-valuef="mb-2 mb-lg-0"/>
<t t-set="_classes" t-value="'me-sm-2'"/>
</t>
<t t-set="website_sale_pricelists" t-value="website.get_pricelist_available(show_visible=True)" />
<t t-set="hasPricelistDropdown" t-value="website_sale_pricelists and len(website_sale_pricelists)&gt;1"/>
<t t-call="website_sale.pricelist_list">
<t t-set="_classes" t-valuef="d-lg-inline ms-2"/>
</t>
</div>
</div>
<div class="col-lg-6 d-flex align-items-center">
<ol class="breadcrumb p-0 mb-2 m-lg-0">
<li class="breadcrumb-item o_not_editable">
<a t-att-href="keep(category=0)">All Products</a>
</li>
<li t-if="category" class="breadcrumb-item">
<a t-att-href="keep('/shop/category/%s' % slug(category), category=0)" t-field="category.name" />
</li>
<li class="breadcrumb-item active">
<span t-field="product.name" />
</li>
</ol>
</div>
</div>
<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">
<t t-set="image_cols" t-value="website._get_product_page_proportions()"/>
<div t-attf-class="col-lg-#{image_cols[0]} mt-lg-4 o_wsale_product_images position-relative" t-if="website.product_page_image_width != 'none'">
<t t-call="website_sale.shop_product_images"/>
</div>
<div t-attf-class="col-lg-#{image_cols[1]} mt-md-4" id="product_details">
<t t-set="base_url" t-value="product.get_base_url()"/>
<h1 itemprop="name" t-field="product.name">Product Name</h1>
<span itemprop="url" style="display:none;" t-esc="base_url + product.website_url"/>
<span itemprop="image" style="display:none;" t-esc="base_url + website.image_url(product, 'image_1920')" />
<t t-if="is_view_active('website_sale.product_comment')">
<a href="#o_product_page_reviews" class="o_product_page_reviews_link text-decoration-none">
<t t-call="portal_rating.rating_widget_stars_static">
<t t-set="rating_avg" t-value="product.rating_avg"/>
<t t-set="trans_text_plural">%s reviews</t>
<t t-set="trans_text_singular">%s review</t>
<t t-set="rating_count" t-value="(trans_text_plural if product.rating_count > 1 else trans_text_singular) % product.rating_count"/>
</t>
</a>
</t>
<p t-field="product.description_sale" class="text-muted my-2" placeholder="A short description that will also appear on documents." />
<form t-if="product._is_add_to_cart_possible()" action="/shop/cart/update" method="POST">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()" t-nocache="The csrf token must always be up to date."/>
<div class="js_product js_main_product mb-3">
<div t-attf-class="{{'d-none' if combination_info['price_call'] else 'test' }} product_price_visible">
<t t-call="website_sale.product_price"/>
<small t-if="combination_info['base_unit_price']"
class="ms-1 text-muted o_base_unit_price_wrapper d-none" groups="website_sale.group_show_uom_price">
<t t-call='website_sale.base_unit_price'/>
</small>
</div>
<t t-placeholder="select">
<input type="hidden" class="product_id" name="product_id" t-att-value="product_variant.id" />
<input type="hidden" class="product_template_id" name="product_template_id" t-att-value="product.id" />
<input t-if="product.public_categ_ids.ids" type="hidden" class="product_category_id" name="product_category_id" t-att-value="product.public_categ_ids.ids[0]" />
<input t-if="product.product_tag_ids.ids" type="hidden" class="product_tag_id" name="product_tag_id" t-att-value="product.product_tag_ids.ids[0]" />
<t t-if="combination" t-call="sale.variants">
<t t-set="ul_class" t-valuef="flex-column" />
<t t-set="parent_combination" t-value="None" />
</t>
<t t-else="">
<ul class="d-none js_add_cart_variants mb-0" t-att-data-attribute_exclusions="{'exclusions: []'}"/>
</t>
</t>
<p t-if="True" class="css_not_available_msg alert alert-warning">This combination does not exist.</p>
<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'}} {{'d-none' if combination_info['price_call'] else 'test' }} 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 id="contact_us_wrapper"
t-attf-class="{{'d-flex' if combination_info['prevent_zero_price_sale'] else 'd-none'}} oe_structure oe_structure_solo #{_div_classes}">
<section class="s_text_block" data-snippet="s_text_block" data-name="Text">
<div class="container">
<a t-att-href="website.contact_us_button_url"
class="btn btn-primary btn_cta">Contact Us
</a>
</div>
</section>
</div>
</div>
</form>
<p t-elif="not product.active" class="alert alert-warning">This product is no longer available.</p>
<p t-else="" class="alert alert-warning">This product has no valid combination.</p>
<div id="product_attributes_simple">
<t t-set="single_value_attributes" t-value="product.valid_product_template_attribute_line_ids._prepare_single_value_for_display()"/>
<table t-attf-class="table table-sm text-muted {{'' if single_value_attributes else 'd-none'}}">
<t t-foreach="single_value_attributes" t-as="attribute">
<tr>
<td>
<span t-field="attribute.name"/>:
<t t-foreach="single_value_attributes[attribute]" t-as="ptal">
<span t-field="ptal.product_template_value_ids._only_active().name"/><t t-if="not ptal_last">, </t>
</t>
</td>
</tr>
</t>
</table>
</div>
<div id="o_product_terms_and_share" class="d-flex justify-content-between flex-column flex-md-row align-items-md-end mb-3">
</div>
</div>
</div>
</section>
</xpath>
<xpath expr="//t[@t-set='hasQuantities']" position="attributes">
<attribute name="t-value" remove="false" add="true" separator=" "/>
</xpath>
<xpath expr="//div[@id='add_to_cart_wrap']" position="before">
<div id="product_unavailable"
t-attf-class="{{'d-flex' if combination_info['prevent_zero_price_sale'] else 'd-none'}}">
<h3 class="fst-italic"
t-field="website.prevent_zero_price_sale_text"/>
</div>
<div id="price_call_hide" style="display:none">
<div>
<div class="alert alert-success" id="alert_message"
style="display:none">
Thank you for information, we will get back to you
asap.
</div>
<a role="button" class="btn btn-primary"
href="#call_for_price"
data-bs-toggle="modal"
id="button_call_for_price">
Call for Price
</a>
</div>
</div>
<div t-attf-class="css_quantity input-group {{'d-none' if combination_info['prevent_zero_price_sale'] else 'd-inline-flex'}} {{'d-none' if combination_info['price_call'] else 'test' }} me-2 mb-2 align-middle #{'input-group-lg' if ctaSizeBig else ''}" contenteditable="false">
<a t-attf-href="#" class="btn btn-link js_add_cart_json" aria-label="Remove one" title="Remove one">
<i class="fa fa-minus"></i>
</a>
<input type="text" class="form-control quantity text-center" data-min="1" name="add_qty" t-att-value="add_qty or 1"/>
<a t-attf-href="#" class="btn btn-link float_left js_add_cart_json" aria-label="Add one" title="Add one">
<i class="fa fa-plus"></i>
</a>
</div>
</xpath>
<xpath expr="//div[@id='o_product_terms_and_share']"
position="before">
<div id="call_for_price" class="modal fade">
<div class="modal-dialog modal-content" style="height:auto">
<div class="page">
<h3>
<center>Call For Price</center>
</h3>
</div>
<input type="hidden" name="product_id" id="product_id"
t-att-value="product.id"/>
<hr/>
<center>
<table style="width:500px">
<tr style="height:60px">
<td style="width:100px">
<label for="first_name"
class="control-label">First
Name:*
</label>
</td>
<td>
<input type="text" class="form-control"
name="first_name"
id="first_name"
required="required"/>
</td>
</tr>
<tr style="height:60px">
<td>
<label for="last_name"
class="control-label">Last Name:
</label>
</td>
<td>
<input type="text" class="form-control"
name="last_name"
id="last_name"/>
</td>
</tr>
<tr style="height:60px">
<td>
<label for="email">Email</label>
</td>
<td>
<input type="text" class="form-control"
name="email"
id="email" required="required"/>
</td>
</tr>
<tr style="height:60px">
<td>
<label for="phone">Contact No.*</label>
</td>
<td>
<input type="text" class="form-control"
id="phone" name="phone"/>
</td>
</tr>
<tr style="height:60px">
<td>
<label>Quantity</label>
</td>
<td>
<input type="number"
class="form-control"
name="quantity" id="quantity"/>
</td>
</tr>
<tr style="height:60px">
<td>
<label>Message</label>
</td>
<td>
<input type="text" class="form-control"
name="message" id="message"/>
</td>
</tr>
</table>
<hr/>
<button id="send_btn" type="button"
data-bs-dismiss="modal"
class="btn btn-primary">Send
</button>
<button type="button"
class="btn btn-outline-secondary"
data-bs-dismiss="modal"
id="call_modal_close">
Close
</button>
</center>
</div>
</div>
</xpath>
</template>
</odoo>
Loading…
Cancel
Save