Skip to content

Commit ce78ba6

Browse files
committed
[ADD] odoo_self_order_details: new module to improve ux during self order
This commit introduces a ux change and more information in the Self-Order functionality. It changes its default functionality of directly adding product into order when clicking to opening a view to show large image and detailed product description so that users can see more details about product whole view page will be scroll-able allowing to configure product depending on their options available Addition of cancel button in footer for better mobile experience
1 parent eb10d6e commit ce78ba6

File tree

7 files changed

+125
-0
lines changed

7 files changed

+125
-0
lines changed

odoo_self_order_details/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "Self Order Details",
3+
"description": """
4+
Self order details for products in POS
5+
""",
6+
"author": "Ayush Patel",
7+
"version": "0.1",
8+
"application": True,
9+
"installable": True,
10+
"depends": ["pos_self_order"],
11+
"license": "LGPL-3",
12+
"assets": {
13+
"pos_self_order.assets": [
14+
"odoo_self_order_details/static/src/**/*",
15+
],
16+
},
17+
"data": [
18+
"views/product_template_view.xml",
19+
],
20+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import product_template
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from odoo import fields, models
2+
3+
4+
class ProductTemplate(models.Model):
5+
_inherit = "product.template"
6+
7+
self_order_description = fields.Html(string="Self-Order Description")
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { patch } from "@web/core/utils/patch";
2+
import { ProductCard } from "@pos_self_order/app/components/product_card/product_card";
3+
import { ProductPage } from "@pos_self_order/app/pages/product_page/product_page";
4+
import { markup } from "@odoo/owl";
5+
6+
patch(ProductCard.prototype, {
7+
async selectProduct(qty = 1) {
8+
const product = this.props.product;
9+
10+
if (!product.self_order_available || !this.isAvailable) {
11+
return;
12+
}
13+
14+
if (product.isCombo()) {
15+
return super.selectProduct(qty);
16+
}
17+
18+
this.router.navigate("product", { id: product.id });
19+
}
20+
});
21+
22+
patch(ProductPage.prototype, {
23+
async setup() {
24+
super.setup();
25+
26+
const product = this.props.product;
27+
if (product && !product.self_order_description) {
28+
try {
29+
const orm = this.env.services.orm;
30+
const [record] = await orm.read("product.product",[product.id],["self_order_description"]);
31+
if (record && record.self_order_description) {
32+
product.self_order_description = markup(record.self_order_description);
33+
}
34+
} catch (err) {
35+
console.error("Failed to fetch self_order_description via ORM:", err);
36+
}
37+
}
38+
},
39+
});
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<templates xml:space="preserve">
3+
<!--Inheriting ProductPage and defining our changes-->
4+
<t t-inherit="pos_self_order.ProductPage" t-inherit-mode="extension">
5+
<!--'options' string after product name only when Product is Configurable -->
6+
<xpath expr="//h1[@class='mb-0 text-nowrap']" position="replace">
7+
<h1 class="mb-0 text-nowrap"><strong t-out="product.name"/> <span t-if="product.isConfigurable()">options</span></h1>
8+
</xpath>
9+
<!-- changes in product details section to have a new layout with a large image and description -->
10+
<xpath expr="//div[hasclass('o-so-product-details')]" position="replace">
11+
<div class="o-so-product-details d-flex flex-column align-items-center p-3 gap-3">
12+
<!-- Large Product Image -->
13+
<div class="o-so-product-details-image text-center mb-3" style="max-width: 300px;">
14+
<img
15+
class="img-fluid rounded shadow-sm"
16+
t-attf-src="/web/image/product.product/{{ product.id }}/image_512"
17+
alt="Product image"
18+
loading="lazy"/>
19+
</div>
20+
21+
<!-- Product related Information -->
22+
<div class="o-so-product-details-description text-center w-100">
23+
<h2 t-out="product.name"/>
24+
<span class="fs-3 d-block my-3" t-out="selfOrder.formatMonetary(selfOrder.getProductDisplayPrice(product))"/>
25+
</div>
26+
27+
<!-- Product Description -->
28+
<div class="o-so-product-details-description text-center w-100">
29+
<t t-if="product.self_order_description">
30+
<div t-out="product.self_order_description"/>
31+
</t>
32+
</div>
33+
</div>
34+
</xpath>
35+
36+
<!--Cancel button next to the Add to cart button -->
37+
<xpath expr="//div[hasclass('page-buttons')]/button[hasclass('btn-primary')]" position="before">
38+
<button class="btn btn-secondary btn-lg" t-on-click="() => router.back()">
39+
Cancel
40+
</button>
41+
</xpath>
42+
</t>
43+
</templates>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo>
3+
<record id="product_template_form_view_inherit_self_order" model="ir.ui.view">
4+
<field name="name">product.template.form.inherit.self.order</field>
5+
<field name="model">product.template</field>
6+
<field name="inherit_id" ref="product.product_template_form_view"/>
7+
<field name="arch" type="xml">
8+
<!-- This XPath targets the 'Point of Sale' page and the 'Point of Sale' group inside it -->
9+
<xpath expr="//page[@name='pos']//group[@name='pos']" position="inside">
10+
<field name="self_order_description"/>
11+
</xpath>
12+
</field>
13+
</record>
14+
</odoo>

0 commit comments

Comments
 (0)