[IMP] nfu_ecommerce: Adapt new Open Packages format and add indicators
This commit is contained in:
parent
344564a1d3
commit
2230bb9488
8 changed files with 105 additions and 71 deletions
|
|
@ -38,9 +38,10 @@ Changelog
|
||||||
:0.0.1: Initial module.
|
:0.0.1: Initial module.
|
||||||
:1.0.0: Live
|
:1.0.0: Live
|
||||||
:1.1.0: Add Open Packagings Filter and fix rounding issue
|
:1.1.0: Add Open Packagings Filter and fix rounding issue
|
||||||
:1.1.1: Make publish on website multi company
|
:1.1.1: Pass arguments to super again
|
||||||
:1.1.2: Pass arguemnts to super again
|
:1.1.2: Make publish on website multi company
|
||||||
:1.2.0: Add Open Packages to Product list
|
:1.2.0: Add Open Packages to Product list
|
||||||
|
:1.3.0: Adapt new Open Packages format and add indicators
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"author": "BAKEUP",
|
"author": "BAKEUP",
|
||||||
"website": "https://www.bakeup.org",
|
"website": "https://www.bakeup.org",
|
||||||
"category": "website",
|
"category": "website",
|
||||||
"version": "16.0.1.2.0",
|
"version": "16.0.1.3.0",
|
||||||
"depends": [
|
"depends": [
|
||||||
"sale_product_configurator",
|
"sale_product_configurator",
|
||||||
"website_sale",
|
"website_sale",
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,9 @@ class WebsiteSale(WebsiteSale):
|
||||||
batch_product = batch_products.filtered(lambda p: p.product_template_id == product)
|
batch_product = batch_products.filtered(lambda p: p.product_template_id == product)
|
||||||
if batch_product:
|
if batch_product:
|
||||||
batch_product = batch_product[0]
|
batch_product = batch_product[0]
|
||||||
if batch_product.open_packaging_state == "full":
|
state_color = batch_product.get_state_color()
|
||||||
|
if state_color == "inherit":
|
||||||
state_color = "green"
|
state_color = "green"
|
||||||
elif batch_product.open_packaging_state == "last_open":
|
|
||||||
state_color = "#ff6700"
|
|
||||||
else:
|
|
||||||
state_color = "red"
|
|
||||||
packaging_info[product.id] = {
|
packaging_info[product.id] = {
|
||||||
"state_color": state_color,
|
"state_color": state_color,
|
||||||
"open_qty": batch_product.open_packaging_qty,
|
"open_qty": batch_product.open_packaging_qty,
|
||||||
|
|
@ -51,15 +48,13 @@ class WebsiteSale(WebsiteSale):
|
||||||
packaging_info = {}
|
packaging_info = {}
|
||||||
if batch_product:
|
if batch_product:
|
||||||
batch_product = batch_product[0]
|
batch_product = batch_product[0]
|
||||||
|
state_color = batch_product.get_state_color()
|
||||||
packaging_info = {
|
packaging_info = {
|
||||||
"state": batch_product.open_packaging_state,
|
"state_color": state_color,
|
||||||
"open_qty": batch_product.open_packaging_qty,
|
"open_qty": batch_product.open_packaging_qty,
|
||||||
|
"open_max_qty": batch_product.open_packaging_max_qty,
|
||||||
"package_qty": batch_product.product_packaging_qty,
|
"package_qty": batch_product.product_packaging_qty,
|
||||||
}
|
}
|
||||||
else:
|
|
||||||
packaging = product.sudo()._get_nfu_packaging()
|
|
||||||
if packaging and packaging.qty > 1:
|
|
||||||
packaging_info = {"state": False, "open_qty": 0, "package_qty": packaging.qty}
|
|
||||||
new_values["packaging_info"] = packaging_info
|
new_values["packaging_info"] = packaging_info
|
||||||
return new_values
|
return new_values
|
||||||
|
|
||||||
|
|
@ -103,3 +98,9 @@ class WebsiteSale(WebsiteSale):
|
||||||
page=page, category=category, search=search, min_price=min_price, max_price=max_price, ppg=ppg, **post
|
page=page, category=category, search=search, min_price=min_price, max_price=max_price, ppg=ppg, **post
|
||||||
)
|
)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
# ToDo: add qntitiy do confiuration modal
|
||||||
|
# def show_advanced_configurator(self, product_id, variant_values, pricelist_id, **kw):
|
||||||
|
# batch = request.website.sale_get_order(force_create=True).batch_id
|
||||||
|
# kw['custom_attribute'] = {'batch_id': batch.id}
|
||||||
|
# return super().show_advanced_configurator(product_id, variant_values, pricelist_id, **kw)
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
from . import product_template
|
from . import product_template
|
||||||
from . import sale_order
|
from . import sale_order
|
||||||
|
from . import sale_order_batch_product
|
||||||
|
|
|
||||||
13
nfu_ecommerce/models/sale_order_batch_product.py
Normal file
13
nfu_ecommerce/models/sale_order_batch_product.py
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
from odoo import models
|
||||||
|
|
||||||
|
|
||||||
|
class SaleOrderBatchProduct(models.Model):
|
||||||
|
_inherit = "sale.order.batch.product"
|
||||||
|
|
||||||
|
def get_state_color(self):
|
||||||
|
self.ensure_one()
|
||||||
|
if self.open_packaging_state == "open":
|
||||||
|
return "red"
|
||||||
|
elif self.open_packaging_state == "last_open":
|
||||||
|
return "orange"
|
||||||
|
return "inherit"
|
||||||
|
|
@ -4,3 +4,4 @@
|
||||||
:1.1.1: Pass arguments to super again
|
:1.1.1: Pass arguments to super again
|
||||||
:1.1.2: Make publish on website multi company
|
:1.1.2: Make publish on website multi company
|
||||||
:1.2.0: Add Open Packages to Product list
|
:1.2.0: Add Open Packages to Product list
|
||||||
|
:1.3.0: Adapt new Open Packages format and add indicators
|
||||||
|
|
|
||||||
|
|
@ -401,10 +401,12 @@ and after the current order.</p>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.1.1:</th><td class="field-body">Pass arguments to super again</td>
|
<tr class="field"><th class="field-name">1.1.1:</th><td class="field-body">Pass arguments to super again</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.1.1:</th><td class="field-body">Make publish on website multi company</td>
|
<tr class="field"><th class="field-name">1.1.2:</th><td class="field-body">Make publish on website multi company</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="field"><th class="field-name">1.2.0:</th><td class="field-body">Add Open Packages to Product list</td>
|
<tr class="field"><th class="field-name">1.2.0:</th><td class="field-body">Add Open Packages to Product list</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="field"><th class="field-name">1.3.0:</th><td class="field-body">Adapt new Open Packages format and add indicators</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,22 @@
|
||||||
active="True"
|
active="True"
|
||||||
name="Show Extra Fields"
|
name="Show Extra Fields"
|
||||||
>
|
>
|
||||||
|
<xpath expr="//span[contains(@t-attf-class,'o_ribbon')]" position="after">
|
||||||
|
<t t-set="template_packaging_vals" t-value="get_product_packagings(product)"/>
|
||||||
|
<t t-if="template_packaging_vals">
|
||||||
|
<span
|
||||||
|
t-attf-class="o_ribbon o_not_editable o_ribbon_right"
|
||||||
|
t-att-style="'color: white; background-color: %s;' % template_packaging_vals['state_color']"
|
||||||
|
t-out="'+%d/+%d'%(template_packaging_vals['open_qty'],template_packaging_vals['open_max_qty'])"
|
||||||
|
/>
|
||||||
|
</t>
|
||||||
|
</xpath>
|
||||||
<xpath expr="//div[hasclass('o_wsale_product_information_text')]" position="after">
|
<xpath expr="//div[hasclass('o_wsale_product_information_text')]" position="after">
|
||||||
<t t-if="any([product[field.name] for field in website.shop_extra_field_ids])">
|
|
||||||
<p class="text-muted">
|
<p class="text-muted">
|
||||||
<t t-foreach='website.shop_extra_field_ids' t-as='field' t-if='product[field.name]'>
|
<t t-foreach='website.shop_extra_field_ids' t-as='field' t-if='product[field.name]'>
|
||||||
<b><t t-esc='field.label'/>: </b>
|
<b><t t-out='field.label'/>: </b>
|
||||||
<t t-if='field.field_id.ttype != "binary"'>
|
<t t-if='field.field_id.ttype != "binary"'>
|
||||||
<span t-esc='product[field.name]' t-options="{'widget': field.field_id.ttype}"/>
|
<span t-out='product[field.name]' t-options="{'widget': field.field_id.ttype}"/>
|
||||||
</t>
|
</t>
|
||||||
<t t-else=''>
|
<t t-else=''>
|
||||||
<a
|
<a
|
||||||
|
|
@ -57,32 +66,26 @@
|
||||||
</t>
|
</t>
|
||||||
<br/>
|
<br/>
|
||||||
</t>
|
</t>
|
||||||
<t t-if="template_packaging_vals">
|
|
||||||
<b>Open Qty: </b><span t-esc="template_packaging_vals['open_qty']"/>/<span
|
|
||||||
t-esc="template_packaging_vals['package_qty']"
|
|
||||||
/><br/>
|
|
||||||
<t t-if="template_packaging_vals['state']">
|
|
||||||
<b>State: </b><span t-esc="template_packaging_vals['state']"/>
|
|
||||||
<br/>
|
|
||||||
</t>
|
|
||||||
</t>
|
|
||||||
</p>
|
</p>
|
||||||
</t>
|
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template id="product_packagings" inherit_id="website_sale.product">
|
<template id="product" inherit_id="website_sale.product">
|
||||||
<xpath expr="//p[@t-field='product.description_sale']" position="after">
|
<xpath expr="//div[@id='o_wsale_cta_wrapper']" position="before">
|
||||||
<div t-if="packaging_info">
|
<t t-if="packaging_info">
|
||||||
<b>Open Qty: </b><span t-esc="packaging_info['open_qty']"/>/<span
|
<div>
|
||||||
t-esc="packaging_info['package_qty']"
|
<span t-out="'+%d/+%d'%(packaging_info['open_qty'],packaging_info['open_max_qty'])"/>
|
||||||
/>
|
|
||||||
<br/>
|
|
||||||
<t t-if="packaging_info['state']">
|
|
||||||
<b>State: </b><span t-esc="packaging_info['state']"/>
|
|
||||||
<br/>
|
|
||||||
</t>
|
|
||||||
</div>
|
</div>
|
||||||
|
</t>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//div[contains(@t-attf-class,'css_quantity')]" position="attributes">
|
||||||
|
<attribute
|
||||||
|
name="t-attf-style"
|
||||||
|
add="background-color: {{packaging_info['state_color']}};"
|
||||||
|
separator=" "
|
||||||
|
t-if="packaging_info"
|
||||||
|
/>
|
||||||
|
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -118,7 +121,7 @@
|
||||||
<template id="cart_lines_packaging" inherit_id="website_sale.cart_lines" name="Shopping Cart Lines">
|
<template id="cart_lines_packaging" inherit_id="website_sale.cart_lines" name="Shopping Cart Lines">
|
||||||
<xpath expr="//td[hasclass('td-product_name')]" position="inside">
|
<xpath expr="//td[hasclass('td-product_name')]" position="inside">
|
||||||
<div t-if="line.product_packaging_id and (line.product_packaging_id.qty != 1)">
|
<div t-if="line.product_packaging_id and (line.product_packaging_id.qty != 1)">
|
||||||
<span>Packaging Size: <t t-esc="line.product_packaging_id.qty"/></span>
|
<span>Packaging Size: <t t-out="line.product_packaging_id.qty"/></span>
|
||||||
</div>
|
</div>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//th[hasclass('td-qty')]" position="after">
|
<xpath expr="//th[hasclass('td-qty')]" position="after">
|
||||||
|
|
@ -130,20 +133,12 @@
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//td[hasclass('td-qty')]" position="attributes">
|
<xpath expr="//td[hasclass('td-qty')]" position="attributes">
|
||||||
<!-- TODO: Fix if-statement -->
|
<!-- TODO: Fix if-statement -->
|
||||||
<attribute
|
<attribute name="t-attf-style" add="background-color: {{line.batch_product_id.get_state_color()}};"/>
|
||||||
t-if="line.batch_product_id.open_packaging_state == 'open'"
|
|
||||||
name="style"
|
|
||||||
>background-color: red;</attribute>
|
|
||||||
<attribute
|
|
||||||
t-if="line.batch_product_id.open_packaging_state == 'last_open'"
|
|
||||||
name="style"
|
|
||||||
>background-color: orange;</attribute>
|
|
||||||
|
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
<xpath expr="//td[hasclass('td-qty')]" position="inside">
|
<xpath expr="//td[hasclass('td-qty')]" position="inside">
|
||||||
<div>
|
<div t-if="line.product_packaging_id">
|
||||||
(+ <t t-out="line.batch_product_id.open_packaging_qty"/>)
|
(+<t t-out="round(line.batch_product_id.open_packaging_qty*10)/10"/>)
|
||||||
</div>
|
</div>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//td[hasclass('td-qty')]" position="after">
|
<xpath expr="//td[hasclass('td-qty')]" position="after">
|
||||||
|
|
@ -199,7 +194,7 @@
|
||||||
</t>
|
</t>
|
||||||
</t>
|
</t>
|
||||||
<t t-else="">
|
<t t-else="">
|
||||||
<span class="text-muted w-100" t-esc="line.product_uom_qty"/>
|
<span class="text-muted w-100" t-out="line.product_uom_qty"/>
|
||||||
<input
|
<input
|
||||||
type="hidden"
|
type="hidden"
|
||||||
class="js_quantity form-control quantity"
|
class="js_quantity form-control quantity"
|
||||||
|
|
@ -210,30 +205,50 @@
|
||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
(+ <t t-out="line.batch_product_id.open_packaging_max_qty"/>)
|
(+<t t-out="round(line.batch_product_id.open_packaging_max_qty*10)/10"/>)
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template id="configure_optional_products" inherit_id="sale_product_configurator.configure_optional_products">
|
<template id="configure_optional_products" inherit_id="sale_product_configurator.configure_optional_products">
|
||||||
|
<!-- TodDo: Add Batch qtys to order modal
|
||||||
|
<xpath expr="//td[hasclass('css_quantity')]" position="before">
|
||||||
|
<div>
|
||||||
|
<t t-out="custom_attribute.batch_id.id"/>
|
||||||
|
(+<t t-out="round(line.batch_product_id.open_packaging_qty*10)/10"/>)
|
||||||
|
</div>
|
||||||
|
</xpath> -->
|
||||||
|
|
||||||
<xpath expr="//th[hasclass('td-qty')]" position="after">
|
<xpath expr="//th[hasclass('td-qty')]" position="after">
|
||||||
<th class="text-center td-max-qty"><span class='label'>Max Quantity</span></th>
|
<th class="text-center td-max-qty"><span class='label'>Max Quantity</span></th>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//td[hasclass('td-qty')]" position="after">
|
<xpath expr="//td[hasclass('td-qty')]" position="after">
|
||||||
|
<!-- TODO: Add JS part
|
||||||
<td class="text-center td-max-qty">
|
<td class="text-center td-max-qty">
|
||||||
<t t-call='nfu_ecommerce.product_max_quantity_config'/>
|
<t t-call='nfu_ecommerce.product_max_quantity_config'/>
|
||||||
</td>
|
</td> -->
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
<template id="cart_hide_checkout_button" inherit_id="website_sale.cart">
|
||||||
|
<!-- TODO: Introduce flag -->
|
||||||
|
<xpath expr="//div[contains(@t-if,'website_sale_order')]" position="attributes">
|
||||||
|
<attribute name="t-if" add="False" separator=" and "/>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
<template id="short_cart_summary_hide_checkout_button" inherit_id="website_sale.short_cart_summary">
|
||||||
|
<!-- TODO: Introduce flag -->
|
||||||
|
<xpath expr="//a[contains(@t-if,'website_sale_order')]" position="attributes">
|
||||||
|
<attribute name="t-if" add="False" separator=" and "/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template id="cart_summary_packaging" inherit_id="website_sale.cart_summary" name="Cart right column">
|
<template id="cart_summary_packaging" inherit_id="website_sale.cart_summary" name="Cart right column">
|
||||||
<xpath expr="//th[hasclass('td-qty')]" position="after">
|
<xpath expr="//th[hasclass('td-qty')]" position="after">
|
||||||
<th class="border-top-0 td-qty">Max Qty</th>
|
<th class="border-top-0 td-qty">Max Qty</th>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//td[hasclass('td-qty')]" position="after">
|
<xpath expr="//td[hasclass('td-qty')]" position="after">
|
||||||
<td class='td-qty'>
|
<td class='td-qty'>
|
||||||
<div t-esc="line.product_uom_max_qty"/>
|
<div t-out="line.product_uom_max_qty"/>
|
||||||
</td>
|
</td>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue