Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] mobile_catalogue_view: redesign product catalog view under sale orders #525

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions mobile_catalogue_view/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

{
'name': "Mobile Catalog View",
'description': "Redesign the mobile catalog view",
'version': '1.0',
'author': "nmak",
'depends': ["sale"],
'data': [
'views/product_template_views.xml',
],
'assets': {
'web.assets_backend': [
'mobile_catalogue_view/static/src/scss/style.scss',
'mobile_catalogue_view/static/src/js/product_image_popup.js',
],
},
'installable': True,
'license': "LGPL-3",
}
52 changes: 52 additions & 0 deletions mobile_catalogue_view/static/src/js/product_image_popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/** @odoo-module **/

import { ProductCatalogKanbanRecord } from "@product/product_catalog/kanban_record";
import { productCatalogKanbanView } from "@product/product_catalog/kanban_view";
import { ProductCatalogKanbanRenderer } from "@product/product_catalog/kanban_renderer";

import { registry } from "@web/core/registry";
import { useFileViewer } from "@web/core/file_viewer/file_viewer_hook";

export class InheritProductMobileCatalog extends ProductCatalogKanbanRecord {
setup() {
super.setup();
this.fileViewer = useFileViewer();
}

onGlobalClick(e) {
const imageContainer = e.target.closest(".o_product_image");
if (imageContainer) {
const imageUrl = e.target.getAttribute("src");
if (imageUrl) {
this.openImagePreview(imageUrl);
return;
}
}
super.onGlobalClick(e);
}

openImagePreview(imageUrl) {
const fileModel = {
isImage: true,
isViewable: true,
displayName: imageUrl,
defaultSource: imageUrl,
downloadUrl: imageUrl,
};
this.fileViewer.open(fileModel);
}
}

export class InheritProductMobileCatalogRenderer extends ProductCatalogKanbanRenderer {
static components = {
...ProductCatalogKanbanRenderer.components,
KanbanRecord: InheritProductMobileCatalog,
};
}

export const ProductMobileKanbanCatalogView = {
...productCatalogKanbanView,
Renderer: InheritProductMobileCatalogRenderer,
};

registry.category("views").add("product_mobile_kanban_catalog", ProductMobileKanbanCatalogView);
9 changes: 9 additions & 0 deletions mobile_catalogue_view/static/src/scss/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@media (max-width: 768px) {
.o_product_image img {
max-width: 150px !important;
max-height: 150px !important;
width: 150px !important;
height: 150px !important;
object-fit: cover;
}
}
16 changes: 16 additions & 0 deletions mobile_catalogue_view/views/product_template_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="product_product_view_kanban_inherit" model="ir.ui.view">
<field name="name">product.product.view.kanban.inherit</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_view_kanban_catalog" />
<field name="arch" type="xml">
<xpath expr="//field[@name='image_128']" position="replace">
<field name="image_1920" class=" ms-auto o_product_image img-fluid" widget="image" />
</xpath>
<xpath expr="//kanban" position="attributes">
<attribute name="js_class">product_mobile_kanban_catalog</attribute>
</xpath>
</field>
</record>
</odoo>