Browse Source

Nov 3 : [FIX] Bug Fixed 'custom_list_view'

pull/295/head
AjmalCybro 2 years ago
parent
commit
a19d3e3b1c
  1. 59
      custom_list_view/README.rst
  2. 3
      custom_list_view/__init__.py
  3. 38
      custom_list_view/__manifest__.py
  4. 22
      custom_list_view/controllers/__init__.py
  5. 68
      custom_list_view/controllers/custom_list_view.py
  6. 8
      custom_list_view/doc/RELEASE_NOTES.md
  7. 13
      custom_list_view/report/custom_list_view_reports.xml
  8. 31
      custom_list_view/report/custom_list_view_templates.xml
  9. BIN
      custom_list_view/static/description/assets/modules/1.png
  10. BIN
      custom_list_view/static/description/assets/modules/2.png
  11. BIN
      custom_list_view/static/description/assets/modules/3.png
  12. BIN
      custom_list_view/static/description/assets/modules/4.png
  13. BIN
      custom_list_view/static/description/assets/modules/5.gif
  14. BIN
      custom_list_view/static/description/assets/modules/6.png
  15. BIN
      custom_list_view/static/description/assets/modules/dynamic_product_fields.png
  16. BIN
      custom_list_view/static/description/assets/modules/dynamic_sale_order_fields.png
  17. BIN
      custom_list_view/static/description/assets/modules/picking_order_line_view.png
  18. BIN
      custom_list_view/static/description/assets/modules/sale_discount_total.png
  19. BIN
      custom_list_view/static/description/assets/modules/sale_order_line_views.png
  20. BIN
      custom_list_view/static/description/assets/modules/sale_purchase_previous_product_cost.png
  21. BIN
      custom_list_view/static/description/assets/screenshots/1.png
  22. BIN
      custom_list_view/static/description/assets/screenshots/2.png
  23. BIN
      custom_list_view/static/description/assets/screenshots/3.png
  24. BIN
      custom_list_view/static/description/assets/screenshots/4.png
  25. BIN
      custom_list_view/static/description/assets/screenshots/5.png
  26. BIN
      custom_list_view/static/description/assets/screenshots/6.png
  27. BIN
      custom_list_view/static/description/assets/screenshots/7.png
  28. BIN
      custom_list_view/static/description/assets/screenshots/duplicate_record.png
  29. BIN
      custom_list_view/static/description/assets/screenshots/hero.gif
  30. BIN
      custom_list_view/static/description/assets/screenshots/highlight_record.png
  31. BIN
      custom_list_view/static/description/assets/screenshots/row_number.png
  32. BIN
      custom_list_view/static/description/assets/screenshots/sticky_header.png
  33. 1101
      custom_list_view/static/description/index.html
  34. 1
      custom_list_view/static/src/css/highlight.css
  35. 30
      custom_list_view/static/src/js/duplicate_record.js
  36. 176
      custom_list_view/static/src/js/list_controller.js
  37. 25
      custom_list_view/static/src/js/list_renderer.js
  38. 34
      custom_list_view/static/src/js/record_highlight.js
  39. 41
      custom_list_view/static/src/xml/list_controller.xml
  40. 65
      custom_list_view/static/src/xml/list_renderer.xml
  41. 18
      custom_list_view/static/src/xml/record_highlight.xml

59
custom_list_view/README.rst

@ -1,15 +1,52 @@
Custom List View V16 .. image:: https://img.shields.io/badge/license-LGPL--3-green.svg
==================== :target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
This module will helps to show row number, fixed header, duplicate record and highlight selected record in list view Custom List View
==================
This module enhances list views by displaying row numbers, maintaining a fixed
header, identifying duplicate records, and highlighting selected records.
Additionally, it facilitates the printing of list views in PDF, CSV, and Excel
formats, allows for the copying of list values to the clipboard, and introduces
a pagination feature.
Configuration
=============
* No additional configurations needed
Company
-------
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__
License
-------
GNU LESSER GENERAL PUBLIC LICENSE, v3.0 (LGPL v3).
(https://www.gnu.org/licenses/lgpl-3.0-standalone.html)
Credits Credits
======= -------
Cybrosys Techno Solutions * Developers : (V16) Rosmy John, Muhsina V
(V15) Aiswarya J P
Author Contact : odoo@cybrosys.com
------
* Cybrosys Techno Solutions <odoo@cybrosys.com> Contacts
Aiswarya J P @ Cybro V15 --------
Rosmy John @ Cybro V16 * Mail Contact : odoo@cybrosys.com
* Website : https://cybrosys.com
Bug Tracker
-----------
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported.
Maintainer
==========
.. image:: https://cybrosys.com/images/logo.png
:target: https://cybrosys.com
This module is maintained by Cybrosys Technologies.
For support and more information, please visit `Our Website <https://cybrosys.com/>`__
Further information
===================
HTML Description: `<static/description/index.html>`__

3
custom_list_view/__init__.py

@ -3,7 +3,7 @@
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2021-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) # Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
# #
# You can modify it under the terms of the GNU LESSER # You can modify it under the terms of the GNU LESSER
@ -19,3 +19,4 @@
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################# #############################################################################
from . import controllers

38
custom_list_view/__manifest__.py

@ -3,7 +3,7 @@
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) # Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
# #
# You can modify it under the terms of the GNU LESSER # You can modify it under the terms of the GNU LESSER
@ -19,30 +19,34 @@
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################# #############################################################################
{ {
'name': 'Custom List View', 'name': 'Custom List View',
'version': '16.0.1.0.1', 'version': '16.0.1.1.0',
'summary': 'Helps to Show Row Number, Fixed Header, Duplicate Record and Highlight Selected Record in List View', 'category': 'Extra Tools',
'description': 'Helps to Show Row Number, Fixed Header, Duplicate Record and Highlight Selected Record in List View', 'summary': 'Helps to Show Row Number, Fixed Header, Duplicate Record, '
'category': 'Tools', 'Highlight Selected Record, Print and Copy Listview items',
'description': "This module Helps to Show Row Number, Fixed Header, "
"Duplicate Record and Highlight Selected Record in List "
"View. Using this module the list view items can be printed"
" in pdf, excel and csv format, Also there is copy to "
"clipboard and pagination features.",
'author': 'Cybrosys Techno Solutions', 'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions', 'maintainer': 'Cybrosys Techno Solutions',
'website': "https://www.cybrosys.com", 'website': 'https://www.cybrosys.com',
'license': 'LGPL-3', 'depends': ['web', 'account'],
'images': ['static/description/banner.png'], 'data': [
'depends': ['base'], 'report/custom_list_view_templates.xml',
'report/custom_list_view_reports.xml'
],
'assets': { 'assets': {
'web.assets_backend': [ 'web.assets_backend': [
'custom_list_view/static/src/js/duplicate_record.js', 'custom_list_view/static/src/**/*',
'custom_list_view/static/src/js/record_highlight.js', ]
'custom_list_view/static/src/css/sticky_header.css',
'custom_list_view/static/src/css/highlight.css',
'custom_list_view/static/src/xml/record_highlight.xml'
],
}, },
'images': ['static/description/banner.png'],
'licence': 'LGPL-3',
'installable': True, 'installable': True,
'auto_install': False, 'auto_install': False,
'application': False, 'application': False
} }

22
custom_list_view/controllers/__init__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from . import custom_list_view

68
custom_list_view/controllers/custom_list_view.py

@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import http
from odoo.http import request
class ExportData(http.Controller):
""" Controller class for exporting data from Odoo models."""
@http.route('/get_data', auth="user", type='json')
def get_export_data(self, **kw):
"""Controller method to fetch required details and export data.
:param kw: Dictionary containing the following keys:
- fields: List of fields to export
- model: Name of the Odoo model
- res_ids: List of record IDs to export (optional)
- domain: Domain for record filtering (optional)
:return: Dictionary containing exported data and column headers"""
model = request.env[kw['model']]
field_names = [field['name'] for field in kw['fields']]
columns_headers = [val['label'].strip() for val in kw['fields']]
domain = [('id', 'in', kw['res_ids'])] \
if kw['res_ids'] else kw['domain']
records = model.browse(kw['res_ids']) \
if kw['res_ids'] \
else model.search(domain, offset=0, limit=False, order=False)
export_data = records.export_data(field_names).get('datas', [])
return {'data': export_data, 'header': columns_headers}
@http.route('/get_data/copy', auth="user", type='json')
def get_export_data_copy(self, **kw):
"""Controller method to fetch required details, export data, and add
column headers.
:param kw: Dictionary containing the following keys:
- fields: List of fields to export
- model: Name of the Odoo model
- res_ids: List of record IDs to export (optional)
- domain: Domain for record filtering (optional)
:return: List of lists containing exported data with column headers"""
model = request.env[kw['model']]
field_names = [field['name'] for field in kw['fields']]
columns_headers = [val['label'].strip() for val in kw['fields']]
domain = [('id', 'in', kw['res_ids'])] \
if kw['res_ids'] else kw['domain']
records = model.browse(kw['res_ids']) \
if kw['res_ids'] \
else model.search(domain, offset=0, limit=False, order=False)
export_data = records.export_data(field_names).get('datas', [])
export_data.insert(0, columns_headers)
return export_data

8
custom_list_view/doc/RELEASE_NOTES.md

@ -2,4 +2,10 @@
#### 14.02.2023 #### 14.02.2023
#### Version 16.0.1.0.0 #### Version 16.0.1.0.0
#### ADD Initial Commit for custom_list_view ##### ADD
- Initial Commit for custom_list_view
#### 26.10.2023
#### Version 16.0.1.1.0
##### UPDT
- Added options for PDF, Excel, and CSV list view printing and implemented pagination.

13
custom_list_view/report/custom_list_view_reports.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Define the action for exporting PDF -->
<record id="action_pdf_list_view" model="ir.actions.report">
<field name="name">Export</field>
<field name="model">ir.exports</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">custom_list_view.print_pdf_listview</field>
<field name="report_file">custom_list_view.print_pdf_listview</field>
<field name="print_report_name">Pdf Report - ${object.name}</field>
<field name="binding_type">report</field>
</record>
</odoo>

31
custom_list_view/report/custom_list_view_templates.xml

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Template for printing a PDF list view. -->
<template id="print_pdf_listview">
<t t-call="web.html_container">
<t t-call="web.internal_layout">
<div class="page">
<table class="table table-bordered"
style="table-layout: fixed">
<!-- Render table headers -->
<t t-foreach="length" t-as="length">
<th style="background-color: #F2F2F2; padding: 10px; color: ">
<span t-out="record['header'][length]"/>
</th>
</t>
<!-- Render table data rows -->
<t t-foreach="record['data']" t-as="rec">
<tr>
<t t-foreach="length+1" t-as="ln">
<td style="background-color: #F2F2F2; padding: 10px;">
<span t-out="rec[ln]"/>
</td>
</t>
</tr>
</t>
</table>
</div>
</t>
</t>
</template>
</odoo>

BIN
custom_list_view/static/description/assets/modules/1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 84 KiB

BIN
custom_list_view/static/description/assets/modules/2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 85 KiB

BIN
custom_list_view/static/description/assets/modules/3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 17 KiB

BIN
custom_list_view/static/description/assets/modules/4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 92 KiB

BIN
custom_list_view/static/description/assets/modules/5.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
custom_list_view/static/description/assets/modules/6.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 81 KiB

BIN
custom_list_view/static/description/assets/modules/dynamic_product_fields.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
custom_list_view/static/description/assets/modules/dynamic_sale_order_fields.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
custom_list_view/static/description/assets/modules/picking_order_line_view.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
custom_list_view/static/description/assets/modules/sale_discount_total.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

BIN
custom_list_view/static/description/assets/modules/sale_order_line_views.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
custom_list_view/static/description/assets/modules/sale_purchase_previous_product_cost.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
custom_list_view/static/description/assets/screenshots/1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

BIN
custom_list_view/static/description/assets/screenshots/2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

BIN
custom_list_view/static/description/assets/screenshots/3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 KiB

BIN
custom_list_view/static/description/assets/screenshots/4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 KiB

BIN
custom_list_view/static/description/assets/screenshots/5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB

BIN
custom_list_view/static/description/assets/screenshots/6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

BIN
custom_list_view/static/description/assets/screenshots/7.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

BIN
custom_list_view/static/description/assets/screenshots/duplicate_record.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB

BIN
custom_list_view/static/description/assets/screenshots/hero.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 599 KiB

BIN
custom_list_view/static/description/assets/screenshots/highlight_record.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

BIN
custom_list_view/static/description/assets/screenshots/row_number.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

BIN
custom_list_view/static/description/assets/screenshots/sticky_header.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

1101
custom_list_view/static/description/index.html

File diff suppressed because it is too large

1
custom_list_view/static/src/css/highlight.css

@ -1,4 +1,3 @@
.o_list_renderer tr.o_data_row.selected_record td{ .o_list_renderer tr.o_data_row.selected_record td{
background-color: #7c7aad; background-color: #7c7aad;
color:#ffffff color:#ffffff

30
custom_list_view/static/src/js/duplicate_record.js

@ -1,30 +0,0 @@
/** @odoo-module */
import { patch } from "@web/core/utils/patch";
import { ListController } from '@web/views/list/list_controller';
const { Component, onWillStart, useSubEnv, useEffect, useRef } = owl;
patch(ListController.prototype, "getActionMenuItems", {
async _onDuplicateSelectedRecords() {
for (var record in this.model.root.records) {
if (this.model.root.records[record].selected) {
await this.model.root.records[record].duplicate();
}
}
window.location.reload();
},
getActionMenuItems() {
const actionMenuItems = this._super.apply(this, arguments);
var self = this;
if (actionMenuItems) {
actionMenuItems.other.splice(1, 0, {
description: this.env._t("Duplicate"),
callback: (x) => {
this._onDuplicateSelectedRecords();
}
});
}
return actionMenuItems;
}
});

176
custom_list_view/static/src/js/list_controller.js

@ -0,0 +1,176 @@
/** @odoo-module */
import { patch } from "@web/core/utils/patch";
import { ListController } from '@web/views/list/list_controller';
import { download } from "@web/core/network/download";
var ajax = require('web.ajax');
var Dialog = require('web.Dialog');
patch(ListController.prototype, "CustomListView", {
/**
* Duplicate selected records and reload the page.
*/
async _onDuplicateSelectedRecords() {
for (var record in this.model.root.records) {
if (this.model.root.records[record].selected) {
await this.model.root.records[record].duplicate();
}
}
window.location.reload();
},
/**
* Get the action menu items and add a "Duplicate" option.
*
* @returns {Object} Action menu items.
*/
getActionMenuItems() {
const actionMenuItems = this._super.apply(this, arguments);
var self = this;
if (actionMenuItems) {
actionMenuItems.other.splice(1, 0, {
description: this.env._t("Duplicate"),
callback: (x) => {
this._onDuplicateSelectedRecords();
}
});
}
return actionMenuItems;
},
/**
* Handle the click event for exporting data to a PDF.
*/
_onClickPDF: async function() {
var self = this;
// Retrieve the fields to export
const fields = this.props.archInfo.columns
.filter((col) => col.optional === false || col.optional === "show")
.map((col) => this.props.fields[col.name])
const exportFields = fields.map((field) => ({
name: field.name,
label: field.label || field.string,
}));
const resIds = await this.getSelectedResIds();
var length_field = Array.from(Array(exportFields.length).keys());
// Make a JSON-RPC request to retrieve the data for the report
ajax.jsonRpc('/get_data', 'call', {
'model': this.model.root.resModel,
'res_ids': resIds.length > 0 && resIds,
'fields': exportFields,
'grouped_by': this.model.root.groupBy,
'context': this.props.context,
'domain': this.model.root.domain,
'context': this.props.context,
}).then(function(data) {
var model = self.model.root.resModel
// Generate and download the PDF report
return self.model.action.doAction({
type: "ir.actions.report",
report_type: "qweb-pdf",
report_name: 'custom_list_view.print_pdf_listview',
report_file: "custom_list_view.print_pdf_listview",
data: {
'length': length_field,
'record': data
}
});
});
},
/**
* Handle the click event for exporting data to Excel.
*/
_onClickExcel: async function() {
// Retrieve the fields to export
const fields = this.props.archInfo.columns
.filter((col) => col.optional === false || col.optional === "show")
.map((col) => this.props.fields[col.name])
.filter((field) => field.exportable !== false);
const exportFields = fields.map((field) => ({
name: field.name,
label: field.label || field.string,
store: field.store,
type: field.field_type || field.type,
}));
const resIds = await this.getSelectedResIds();
const import_compat = false
// Make a request to download the Excel file
await download({
data: {
data: JSON.stringify({
import_compat,
context: this.props.context,
domain: this.model.root.domain,
fields: exportFields,
groupby: this.model.root.groupBy,
ids: resIds.length > 0 && resIds,
model: this.model.root.resModel,
}),
},
url: `/web/export/xlsx`,
});
},
/**
* Handle the click event for exporting data to CSV.
*/
_onClickCSV: async function() {
const fields = this.props.archInfo.columns
.filter((col) => col.optional === false || col.optional === "show")
.map((col) => this.props.fields[col.name])
.filter((field) => field.exportable !== false);
const exportFields = fields.map((field) => ({
name: field.name,
label: field.label || field.string,
store: field.store,
type: field.field_type || field.type,
}));
const resIds = await this.getSelectedResIds();
const import_compat = false
// Make a request to download the CSV file
await download({
data: {
data: JSON.stringify({
import_compat,
context: this.props.context,
domain: this.model.root.domain,
fields: exportFields,
groupby: this.model.root.groupBy,
ids: resIds.length > 0 && resIds,
model: this.model.root.resModel,
}),
},
url: `/web/export/csv`,
});
},
/**
* Handle the click event for copying data to the clipboard.
*/
_onClickCopy: async function() {
var self = this;
// Retrieve the fields to export
const fields = this.props.archInfo.columns
.filter((col) => col.type === "field")
.map((col) => this.props.fields[col.name])
const exportFields = fields.map((field) => ({
name: field.name,
label: field.label || field.string,
}));
const resIds = await this.getSelectedResIds();
var length_field = Array.from(Array(exportFields.length).keys());
// Make a JSON-RPC request to retrieve the data to copy
ajax.jsonRpc('/get_data/copy', 'call', {
'model': this.model.root.resModel,
'res_ids': resIds.length > 0 && resIds,
'fields': exportFields,
'grouped_by': this.model.root.groupBy,
'context': this.props.context,
'domain': this.model.root.domain,
'context': this.props.context,
}).then(function(data) {
// Format the data as text and copy it to the clipboard
var recText = data.map(function(record) {
return record.join("\t"); // Join the elements of each array with tabs ("\t")
}).join("\n");
// Copy the recText to the clipboard
navigator.clipboard.writeText(recText);
Dialog.alert(self, "Records Copied to Clipboard ", {});
});
},
});

25
custom_list_view/static/src/js/list_renderer.js

@ -0,0 +1,25 @@
/** @odoo-module **/
import { session } from "@web/session";
import { ListRenderer } from "@web/views/list/list_renderer";
import { patch } from "@web/core/utils/patch";
import { browser } from "@web/core/browser/browser";
import { useService } from "@web/core/utils/hooks";
const {onMounted} = owl;
/**
* Patched function to toggle record selection and add a CSS class to selected records.
*
* @param {Object} record - The record to toggle selection for.
*/
patch(ListRenderer.prototype, 'custom_list_view/static/src/js/list_renderer.js', {
toggleRecordSelection(record) {
var self = this;
this._super.apply(this, arguments);
var selectedRecord = $(event.target).closest('tr')
if ($(event.target).prop('checked')) {
selectedRecord.addClass('selected_record');
} else {
selectedRecord.removeClass('selected_record')
}
}
});

34
custom_list_view/static/src/js/record_highlight.js

@ -1,34 +0,0 @@
/** @odoo-module **/
import { session } from "@web/session";
import { ListRenderer } from "@web/views/list/list_renderer";
import { patch } from "@web/core/utils/patch";
import { browser } from "@web/core/browser/browser";
import { useService } from "@web/core/utils/hooks";
const {onMounted} = owl;
patch(ListRenderer.prototype, 'custom_list_view/static/src/js/record_highlight.js', {
setup(){
this._super(...arguments)
onMounted(() => {
var tdElement = document.createElement('td');
var thElement = document.createElement('th');
thElement.innerText = "Sl No"
thElement.style.width = "60px"
var firstRow = $(this.__owl__.bdom.parentEl.querySelectorAll('.o_list_table')).find('thead tr').first();
var secondRow = $(this.__owl__.bdom.parentEl.querySelectorAll('.o_list_footer')).find('tr').first();
firstRow.prepend(thElement);
secondRow.prepend(tdElement);
});
},
toggleRecordSelection(record) {
var self = this;
this._super.apply(this, arguments);
var selectedRecord = $(event.target).closest('tr')
if($(event.target).prop('checked')){
selectedRecord.addClass('selected_record');
} else {
selectedRecord.removeClass('selected_record')
}
}
})

41
custom_list_view/static/src/xml/list_controller.xml

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<!-- Extension template for adding buttons in the listview -->
<t t-inherit="web.ListView.Buttons" t-inherit-mode="extension">
<!-- Add buttons after the 'Export Excel' button -->
<xpath expr="//*[@class='btn btn-secondary fa fa-download o_list_export_xlsx']"
position="after">
<!-- Print PDF button -->
<button type="button" class="btn btn-secondary "
t-on-click="_onClickPDF" data-tooltip="Print PDF" >PDF</button>
<!-- Print Excel button -->
<button type="button" class="btn btn-secondary"
t-on-click="_onClickExcel" data-tooltip="Print Excel" >Excel</button>
<!-- Print CSV button -->
<button type="button" class="btn btn-secondary"
t-on-click="_onClickCSV" data-tooltip="Print CSV" >CSV</button>
<!-- Copy to Clipboard button -->
<button type="button" class="btn btn-secondary fa fa-clipboard"
t-on-click="_onClickCopy" data-tooltip="Copy to Clipboard"/>
</xpath>
</t>
<!-- Extension template for adding buttons in the invoice listview -->
<t t-inherit="account.ListView.Buttons" t-inherit-mode="extension">
<!-- Add buttons after the 'Export Excel' button -->
<xpath expr="//*[@class='btn btn-secondary fa fa-download o_list_export_xlsx']"
position="after">
<!-- Print PDF button -->
<button type="button" class="btn btn-secondary"
t-on-click="_onClickPDF" data-tooltip="Print PDF">PDF</button>
<!-- Print Excel button -->
<button type="button" class="btn btn-secondary"
t-on-click="_onClickExcel" data-tooltip="Print Excel">Excel</button>
<!-- Print CSV button -->
<button type="button" class="btn btn-secondary"
t-on-click="_onClickCSV" data-tooltip="Print CSV">CSV</button>
<!-- Copy to Clipboard button -->
<button type="button" class="btn btn-secondary fa fa-clipboard"
t-on-click="_onClickCopy" data-tooltip="Copy to Clipboard"/>
</xpath>
</t>
</templates>

65
custom_list_view/static/src/xml/list_renderer.xml

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- XML template for rendering lists with pagination information -->
<templates xml:space="preserve">
<t t-inherit="web.ListRenderer" t-inherit-mode="extension">
<xpath expr="//*[@class='o_list_renderer o_renderer table-responsive']"
position="after">
<!-- Pagination in lists -->
<div class="o_list_pagination" style=" text-align: end;">
Showing from
<t t-if="this.props.list.groups">
<t t-esc="this.env.config.pagerProps.offset+1"/> -
<t t-esc="this.env.config.pagerProps.offset + this.props.list.groups.length"/></t>
<t t-else="">
<t t-esc="this.env.config.pagerProps.offset+1"/> -
<t t-esc="this.env.config.pagerProps.offset+this.props.list.records.length"/></t>
of
<t t-esc="this.props.list.count"/>
Records
</div>
</xpath>
<xpath expr="//th[@t-if='hasSelectors']" position="before">
<th style="width: 60px">Sl No</th>
<t t-set="RowNumber" t-value="1" />
</xpath>
</t>
<t t-inherit="account.ListRenderer" t-inherit-mode="extension">
<xpath expr="//*[@class='o_list_renderer o_renderer table-responsive']"
position="after">
<!-- Pagination in invoice list -->
<div class="o_list_pagination" style=" text-align: end;">
Showing from
<t t-if="this.props.list.groups">
<t t-esc="this.env.config.pagerProps.offset+1"/> -
<t t-esc="this.env.config.pagerProps.offset + this.props.list.groups.length"/></t>
<t t-else="">
<t t-esc="this.env.config.pagerProps.offset+1"/> -
<t t-esc="this.env.config.pagerProps.offset+this.props.list.records.length"/></t>
of
<t t-esc="this.props.list.count"/>
Records
</div>
</xpath>
</t>
<t t-inherit="web.ListRenderer.Rows" t-inherit-mode="extension" owl="1">
<xpath expr="//t[@t-foreach='list.records']" position="before">
<t t-set="RowNumber" t-value="1" />
</xpath>
<xpath expr="//t[@t-call='{{ constructor.recordRowTemplate }}']" position="after">
<t t-set="RowNumber" t-value="RowNumber+1" />
</xpath>
</t>
<t t-inherit="web.ListRenderer.RecordRow" t-inherit-mode="extension" owl="1">
<xpath expr="//td[@class='o_list_record_selector']" position="before">
<td tabindex="-1">
<span t-esc="RowNumber" />
</td>
</xpath>
</t>
</templates>

18
custom_list_view/static/src/xml/record_highlight.xml

@ -1,18 +0,0 @@
<templates id="template" xml:space="preserve">
<t t-name="custom_list_view.add_number" t-inherit="web.ListRenderer.Rows" t-inherit-mode="extension" owl="1">
<xpath expr="//t[@t-foreach='list.records']" position="before">
<t t-set="RowNumber" t-value="1" />
</xpath>
<xpath expr="//t[@t-call='{{ constructor.recordRowTemplate }}']" position="after">
<t t-set="RowNumber" t-value="RowNumber+1" />
</xpath>
</t>
<t t-name="rowno_in_tree.ListRenderer.RecordRowNumber" t-inherit="web.ListRenderer.RecordRow" t-inherit-mode="extension" owl="1">
<xpath expr="//td[@class='o_list_record_selector']" position="before">
<td tabindex="-1">
<span t-esc="RowNumber" />
</td>
</xpath>
</t>
</templates>
Loading…
Cancel
Save