Skip to content

Commit 1f290c1

Browse files
committed
[ADD] mobile_catalogue_view: redesign product catalog view under sale orders
Made the image size bigger and clearer by replacing image_128 with image_1024, ensuring responsiveness. Added image preview functionality for product images in the mobile Kanban view. Used the useFileViewer hook to enable full-screen and zoomable image previews for products. Task- 4618902
1 parent 4c650f3 commit 1f290c1

File tree

4 files changed

+99
-0
lines changed

4 files changed

+99
-0
lines changed

mobile_catalogue_view/__manifest__.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
{
4+
'name': "Mobile Catalog View",
5+
'description': "Redesign the mobile catalog view",
6+
'version': '1.0',
7+
'author': "nmak",
8+
'depends': ["sale"],
9+
'data': [
10+
'views/product_template_views.xml',
11+
],
12+
'assets': {
13+
'web.assets_backend': [
14+
'mobile_catalogue_view/static/src/scss/style.scss',
15+
'mobile_catalogue_view/static/src/js/product_image_popup.js',
16+
],
17+
},
18+
'installable': True,
19+
'license': "LGPL-3",
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/** @odoo-module **/
2+
3+
import { registry } from "@web/core/registry";
4+
import { ProductCatalogKanbanRecord } from "@product/product_catalog/kanban_record";
5+
import { productCatalogKanbanView } from "@product/product_catalog/kanban_view";
6+
import { ProductCatalogKanbanRenderer } from "@product/product_catalog/kanban_renderer";
7+
import { useFileViewer } from "@web/core/file_viewer/file_viewer_hook";
8+
9+
export class InheritProductMobileCatalog extends ProductCatalogKanbanRecord {
10+
setup() {
11+
super.setup()
12+
this.fileViewer = useFileViewer();
13+
}
14+
15+
onGlobalClick(e) {
16+
const imageContainer = e.target.closest('.o_product_image');
17+
if(imageContainer){
18+
const imageUrl = e.target.getAttribute("src");
19+
console.log(imageUrl);
20+
21+
if(imageUrl){
22+
this.openImagePreview(imageUrl);
23+
return;
24+
}
25+
}
26+
super.onGlobalClick(e);
27+
}
28+
29+
openImagePreview(imageUrl) {
30+
const fileModel = {
31+
isImage: true,
32+
isViewable: true,
33+
displayName: imageUrl,
34+
defaultSource: imageUrl,
35+
downloadUrl: imageUrl,
36+
}
37+
this.fileViewer.open(fileModel);
38+
}
39+
}
40+
41+
//Adding InheritProductMobileCatalog component to the Kanban renderer for the Kanban view
42+
export class InheritProductMobileCatalogRenderer extends ProductCatalogKanbanRenderer {
43+
static components = {
44+
...ProductCatalogKanbanRenderer.components,
45+
KanbanRecord: InheritProductMobileCatalog,
46+
};
47+
}
48+
49+
export const ProductMobileKanbanCatalogView = {
50+
...productCatalogKanbanView,
51+
Renderer: InheritProductMobileCatalogRenderer,
52+
};
53+
54+
registry.category("views").add("product_mobile_kanban_catalog", ProductMobileKanbanCatalogView);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@media (max-width: 768px) {
2+
.o_product_image img {
3+
max-width: 150px !important;
4+
max-height: 150px !important;
5+
width: 150px !important;
6+
height: 150px !important;
7+
object-fit: cover;
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<record id="product_product_view_kanban_inherit" model="ir.ui.view">
4+
<field name="name">product.product.view.kanban.inherit</field>
5+
<field name="model">product.product</field>
6+
<field name="inherit_id" ref="product.product_view_kanban_catalog" />
7+
<field name="arch" type="xml">
8+
<xpath expr="//field[@name='image_128']" position="replace">
9+
<field name="image_1920" class=" ms-auto o_product_image img-fluid" widget="image" />
10+
</xpath>
11+
<xpath expr="//kanban" position="attributes">
12+
<attribute name="js_class">product_mobile_kanban_catalog</attribute>
13+
</xpath>
14+
</field>
15+
</record>
16+
</odoo>

0 commit comments

Comments
 (0)