diff --git a/custom_list_view/README.rst b/custom_list_view/README.rst index 5fb6bb857..4095c8f83 100644 --- a/custom_list_view/README.rst +++ b/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 `__ + +License +------- +GNU LESSER GENERAL PUBLIC LICENSE, v3.0 (LGPL v3). +(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) Credits -======= -Cybrosys Techno Solutions - -Author ------- -* Cybrosys Techno Solutions - Aiswarya J P @ Cybro V15 - Rosmy John @ Cybro V16 +------- +* Developers : (V16) Rosmy John, Muhsina V + (V15) Aiswarya J P + Contact : odoo@cybrosys.com + +Contacts +-------- +* 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 `__ + +Further information +=================== +HTML Description: ``__ diff --git a/custom_list_view/__init__.py b/custom_list_view/__init__.py index e2604cae1..304a6d19b 100644 --- a/custom_list_view/__init__.py +++ b/custom_list_view/__init__.py @@ -3,7 +3,7 @@ # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2021-TODAY Cybrosys Technologies() +# Copyright (C) 2023-TODAY Cybrosys Technologies() # Author: Cybrosys Techno Solutions() # # You can modify it under the terms of the GNU LESSER @@ -19,3 +19,4 @@ # If not, see . # ############################################################################# +from . import controllers diff --git a/custom_list_view/__manifest__.py b/custom_list_view/__manifest__.py index a92fdce80..8eebe9c28 100644 --- a/custom_list_view/__manifest__.py +++ b/custom_list_view/__manifest__.py @@ -3,7 +3,7 @@ # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2022-TODAY Cybrosys Technologies() +# Copyright (C) 2023-TODAY Cybrosys Technologies() # Author: Cybrosys Techno Solutions() # # You can modify it under the terms of the GNU LESSER @@ -19,30 +19,34 @@ # If not, see . # ############################################################################# - { 'name': 'Custom List View', - 'version': '16.0.1.0.1', - 'summary': 'Helps to Show Row Number, Fixed Header, Duplicate Record and Highlight Selected Record in List View', - 'description': 'Helps to Show Row Number, Fixed Header, Duplicate Record and Highlight Selected Record in List View', - 'category': 'Tools', + 'version': '16.0.1.1.0', + 'category': 'Extra Tools', + 'summary': 'Helps to Show Row Number, Fixed Header, Duplicate Record, ' + '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', 'company': 'Cybrosys Techno Solutions', 'maintainer': 'Cybrosys Techno Solutions', - 'website': "https://www.cybrosys.com", - 'license': 'LGPL-3', - 'images': ['static/description/banner.png'], - 'depends': ['base'], + 'website': 'https://www.cybrosys.com', + 'depends': ['web', 'account'], + 'data': [ + 'report/custom_list_view_templates.xml', + 'report/custom_list_view_reports.xml' + ], 'assets': { 'web.assets_backend': [ - 'custom_list_view/static/src/js/duplicate_record.js', - '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' - ], + 'custom_list_view/static/src/**/*', + ] }, + 'images': ['static/description/banner.png'], + 'licence': 'LGPL-3', 'installable': True, 'auto_install': False, - 'application': False, + 'application': False } diff --git a/custom_list_view/controllers/__init__.py b/custom_list_view/controllers/__init__.py new file mode 100644 index 000000000..e4b7d8d65 --- /dev/null +++ b/custom_list_view/controllers/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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 . +# +############################################################################# +from . import custom_list_view diff --git a/custom_list_view/controllers/custom_list_view.py b/custom_list_view/controllers/custom_list_view.py new file mode 100644 index 000000000..7f6e1105f --- /dev/null +++ b/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() +# Author: Cybrosys Techno Solutions() +# +# 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 . +# +############################################################################# +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 diff --git a/custom_list_view/doc/RELEASE_NOTES.md b/custom_list_view/doc/RELEASE_NOTES.md index 6614bb0be..7923fcfeb 100644 --- a/custom_list_view/doc/RELEASE_NOTES.md +++ b/custom_list_view/doc/RELEASE_NOTES.md @@ -2,4 +2,10 @@ #### 14.02.2023 #### 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. diff --git a/custom_list_view/report/custom_list_view_reports.xml b/custom_list_view/report/custom_list_view_reports.xml new file mode 100644 index 000000000..481be12d3 --- /dev/null +++ b/custom_list_view/report/custom_list_view_reports.xml @@ -0,0 +1,13 @@ + + + + + Export + ir.exports + qweb-pdf + custom_list_view.print_pdf_listview + custom_list_view.print_pdf_listview + Pdf Report - ${object.name} + report + + diff --git a/custom_list_view/report/custom_list_view_templates.xml b/custom_list_view/report/custom_list_view_templates.xml new file mode 100644 index 000000000..edee976ec --- /dev/null +++ b/custom_list_view/report/custom_list_view_templates.xml @@ -0,0 +1,31 @@ + + + + + diff --git a/custom_list_view/static/description/assets/modules/1.png b/custom_list_view/static/description/assets/modules/1.png index 5238bdeab..489f44e86 100644 Binary files a/custom_list_view/static/description/assets/modules/1.png and b/custom_list_view/static/description/assets/modules/1.png differ diff --git a/custom_list_view/static/description/assets/modules/2.png b/custom_list_view/static/description/assets/modules/2.png index 1ae7cfe3b..273effef7 100644 Binary files a/custom_list_view/static/description/assets/modules/2.png and b/custom_list_view/static/description/assets/modules/2.png differ diff --git a/custom_list_view/static/description/assets/modules/3.png b/custom_list_view/static/description/assets/modules/3.png index 3c3ff1afb..55fb7ba18 100644 Binary files a/custom_list_view/static/description/assets/modules/3.png and b/custom_list_view/static/description/assets/modules/3.png differ diff --git a/custom_list_view/static/description/assets/modules/4.png b/custom_list_view/static/description/assets/modules/4.png index 3fae4631e..c1f30354a 100644 Binary files a/custom_list_view/static/description/assets/modules/4.png and b/custom_list_view/static/description/assets/modules/4.png differ diff --git a/custom_list_view/static/description/assets/modules/5.gif b/custom_list_view/static/description/assets/modules/5.gif index 2a5f8e659..8f40aab85 100644 Binary files a/custom_list_view/static/description/assets/modules/5.gif and b/custom_list_view/static/description/assets/modules/5.gif differ diff --git a/custom_list_view/static/description/assets/modules/6.png b/custom_list_view/static/description/assets/modules/6.png index 7f2815273..31ed46762 100644 Binary files a/custom_list_view/static/description/assets/modules/6.png and b/custom_list_view/static/description/assets/modules/6.png differ diff --git a/custom_list_view/static/description/assets/modules/dynamic_product_fields.png b/custom_list_view/static/description/assets/modules/dynamic_product_fields.png new file mode 100644 index 000000000..55fb7ba18 Binary files /dev/null and b/custom_list_view/static/description/assets/modules/dynamic_product_fields.png differ diff --git a/custom_list_view/static/description/assets/modules/dynamic_sale_order_fields.png b/custom_list_view/static/description/assets/modules/dynamic_sale_order_fields.png new file mode 100644 index 000000000..febd12d15 Binary files /dev/null and b/custom_list_view/static/description/assets/modules/dynamic_sale_order_fields.png differ diff --git a/custom_list_view/static/description/assets/modules/picking_order_line_view.png b/custom_list_view/static/description/assets/modules/picking_order_line_view.png new file mode 100644 index 000000000..b8ea6b411 Binary files /dev/null and b/custom_list_view/static/description/assets/modules/picking_order_line_view.png differ diff --git a/custom_list_view/static/description/assets/modules/sale_discount_total.png b/custom_list_view/static/description/assets/modules/sale_discount_total.png new file mode 100644 index 000000000..3add135c3 Binary files /dev/null and b/custom_list_view/static/description/assets/modules/sale_discount_total.png differ diff --git a/custom_list_view/static/description/assets/modules/sale_order_line_views.png b/custom_list_view/static/description/assets/modules/sale_order_line_views.png new file mode 100644 index 000000000..624ef69b7 Binary files /dev/null and b/custom_list_view/static/description/assets/modules/sale_order_line_views.png differ diff --git a/custom_list_view/static/description/assets/modules/sale_purchase_previous_product_cost.png b/custom_list_view/static/description/assets/modules/sale_purchase_previous_product_cost.png new file mode 100644 index 000000000..61bb0ced0 Binary files /dev/null and b/custom_list_view/static/description/assets/modules/sale_purchase_previous_product_cost.png differ diff --git a/custom_list_view/static/description/assets/screenshots/1.png b/custom_list_view/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..06f6abc38 Binary files /dev/null and b/custom_list_view/static/description/assets/screenshots/1.png differ diff --git a/custom_list_view/static/description/assets/screenshots/2.png b/custom_list_view/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..eca7b1a00 Binary files /dev/null and b/custom_list_view/static/description/assets/screenshots/2.png differ diff --git a/custom_list_view/static/description/assets/screenshots/3.png b/custom_list_view/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..7523d6352 Binary files /dev/null and b/custom_list_view/static/description/assets/screenshots/3.png differ diff --git a/custom_list_view/static/description/assets/screenshots/4.png b/custom_list_view/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..62ab3d79a Binary files /dev/null and b/custom_list_view/static/description/assets/screenshots/4.png differ diff --git a/custom_list_view/static/description/assets/screenshots/5.png b/custom_list_view/static/description/assets/screenshots/5.png new file mode 100644 index 000000000..808e0021c Binary files /dev/null and b/custom_list_view/static/description/assets/screenshots/5.png differ diff --git a/custom_list_view/static/description/assets/screenshots/6.png b/custom_list_view/static/description/assets/screenshots/6.png new file mode 100644 index 000000000..96202dc87 Binary files /dev/null and b/custom_list_view/static/description/assets/screenshots/6.png differ diff --git a/custom_list_view/static/description/assets/screenshots/7.png b/custom_list_view/static/description/assets/screenshots/7.png new file mode 100644 index 000000000..c2b9f8eb8 Binary files /dev/null and b/custom_list_view/static/description/assets/screenshots/7.png differ diff --git a/custom_list_view/static/description/assets/screenshots/duplicate_record.png b/custom_list_view/static/description/assets/screenshots/duplicate_record.png deleted file mode 100644 index 5b9d4d16f..000000000 Binary files a/custom_list_view/static/description/assets/screenshots/duplicate_record.png and /dev/null differ diff --git a/custom_list_view/static/description/assets/screenshots/hero.gif b/custom_list_view/static/description/assets/screenshots/hero.gif index 5f1570259..59f9c8065 100644 Binary files a/custom_list_view/static/description/assets/screenshots/hero.gif and b/custom_list_view/static/description/assets/screenshots/hero.gif differ diff --git a/custom_list_view/static/description/assets/screenshots/highlight_record.png b/custom_list_view/static/description/assets/screenshots/highlight_record.png deleted file mode 100644 index 52917b10a..000000000 Binary files a/custom_list_view/static/description/assets/screenshots/highlight_record.png and /dev/null differ diff --git a/custom_list_view/static/description/assets/screenshots/row_number.png b/custom_list_view/static/description/assets/screenshots/row_number.png deleted file mode 100644 index 36406feb8..000000000 Binary files a/custom_list_view/static/description/assets/screenshots/row_number.png and /dev/null differ diff --git a/custom_list_view/static/description/assets/screenshots/sticky_header.png b/custom_list_view/static/description/assets/screenshots/sticky_header.png deleted file mode 100644 index e39baaeb6..000000000 Binary files a/custom_list_view/static/description/assets/screenshots/sticky_header.png and /dev/null differ diff --git a/custom_list_view/static/description/index.html b/custom_list_view/static/description/index.html index fa0aedf4a..88c7b7af0 100644 --- a/custom_list_view/static/description/index.html +++ b/custom_list_view/static/description/index.html @@ -1,543 +1,682 @@
- -
- -
-
- Community -
-
- Enterprise -
-
- Odoo.sh -
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
-
- -
-
-
- -

- Custom List View

-

Helps to Show Row Number, Fixed Header, Duplicate Record and Highlight Selected Record in List View.

- - -
+ +
+
+
+ +

+ Custom List View +

+

+ Show Row Number, Fixed Header, Duplicate Record and + Highlight Selected Record in List View. + Export List to Pdf, Excel and CSV. Copy to Clipboard and + Pagination +

+ + +
+
-
- -
-
-
- -
-

Explore This - Module

+
+
+ +
+

+ Explore This + Module

-
-
- -
-

Overview -

+
+
+ +
+

+ Overview +

-
-
-This module will ensure sticky headers, row numbers, duplicate records and record highlight for list - view and enhance the user experience.
+
+
+ This module ensures sticky headers, row numbers, duplicate record + , and record highlighting for list views. It also enables the export + of lists in PDF, Excel, and CSV formats, along with providing + copy-to-clipboard and pagination options. +
-
-
- -
-

Features -

-
-
-
-
- - Sticky Header in List Views. +
+
+
-
- - Row Numbers in List Views. -
-
- - Able to Duplicate Records from List Views. -
-
- - Able to Highlight Selected Records in list view. +

+ Features +

+
+
+
+
+ + Sticky Header in List Views. + +
+
+ + Row Numbers in List Views. + +
+
+ + Able to Duplicate Records from List Views. + +
+
+ + Able to Highlight Selected Records in list view. + +
+
+ + Export list to PDF, CSV & Excel. + +
+
+ + Copy List values to clipboard. +
+
+ + Datatable pagination. +
-
-
-
- -
-

Screenshots -

+
+
+ +
+

+ Screenshots +

-
- -
-

Sticky Header in List Views -

- -
- -
-

Row Numbers in List Views -

- -
- -
-

Duplicate Records From List Views -

- -
-
-

Highlight Records From List Views. -

- +
+
+

+ Sticky Header in List Views. +

+ +
+
+

+ Row Numbers in List Views. +

+ +
+
+

+ Duplicate Records From List Views. +

+ +
+
+

+ Highlight Records From List Views. +

+ +
+
+

+ Export ,Copy to Clipboard And Pagination. +

+

+ We can easily export the list to PDF, Excel, and CSV formats by + clicking the respective buttons. + Clicking the copy-to-clipboard icon allows us to copy the list + values, which can then be pasted anywhere we choose. + Pagination is displayed at the bottom of the list view.

+ +
+
+

+ Copy to Clipboard +

+

+ Upon copying the values to the clipboard, an alert will be + displayed indicating that the records have been successfully + copied.

+ +
+
+

+ Pagination. +

+

+ When filtering the records, pagination is displayed at the + bottom.

+ +
- -
-
-
- -
-

Related - Products -

+
+
+ +
+

+ Related + Products +

-
-
- -
-
- -
-

Our Services -

+
+
+ +
+

+ Our Services +

-
-
-
-
- -
-
- Odoo - Customization
-
- -
-
- -
-
- Odoo - Implementation
-
- -
-
- -
-
- Odoo - Support
-
- - -
-
- -
-
- Hire - Odoo - Developer
-
- -
-
- -
-
- Odoo - Integration
-
- -
-
- -
-
- Odoo - Migration
-
- - -
-
- -
-
- Odoo - Consultancy
-
- -
-
- -
-
- Odoo - Implementation
-
- -
-
- -
-
- Odoo - Licensing Consultancy
+
+
+
+ +
+
+ Odoo + Customization
+
+
+
+ +
+
+ Odoo + Implementation
+
+
+
+ +
+
+ Odoo + Support
+
+
+
+ +
+
+ Hire + Odoo + Developer
+
+
+
+ +
+
+ Odoo + Integration
+
+
+
+ +
+
+ Odoo + Migration
+
+
+
+ +
+
+ Odoo + Consultancy
+
+
+
+ +
+
+ Odoo + Implementation
+
+
+
+ +
+
+ Odoo + Licensing Consultancy
+
-
-
- - + - -
-
- -
-

Our - Industries -

+
+
+ +
+

+ Our + Industries +

-
-
-
-
- -
- Trading -
-

- Easily procure - and - sell your products

-
-
- -
-
- -
- POS -
-

- Easy - configuration - and convivial experience

-
-
- -
-
- -
- Education -
-

- A platform for - educational management

-
-
- -
-
- -
- Manufacturing -
-

- Plan, track and - schedule your operations

-
-
- -
-
- -
- E-commerce & Website -
-

- Mobile - friendly, - awe-inspiring product pages

-
-
- -
-
- -
- Service Management -
-

- Keep track of - services and invoice

-
-
- -
-
- -
- Restaurant -
-

- Run your bar or - restaurant methodically

-
-
- -
-
- -
- Hotel Management -
-

- An - all-inclusive - hotel management application

-
+
+
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
-
- - + -
-
- -
-

Support -

+
+
+ +
+

+ Support +

-
-
-
-
- +
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? + Get in touch.

+ +

+ odoo@cybrosys.com

+
+
+
-
-

Need Help?

-

Got questions or need help? Get in touch.

- -

- odoo@cybrosys.com

-
-
-
-
-
-
-
- +
+
+
+ +
+
+

WhatsApp

+

Say hi to us on WhatsApp!

+ +

+ +91 86068 + 27707

+
+
+
-
-

WhatsApp

-

Say hi to us on WhatsApp!

- -

+91 86068 - 27707

-
-
-
-
-
-
- +
+
+ +
-
- + \ No newline at end of file diff --git a/custom_list_view/static/src/css/highlight.css b/custom_list_view/static/src/css/highlight.css index 156078a9b..b8e5ff559 100644 --- a/custom_list_view/static/src/css/highlight.css +++ b/custom_list_view/static/src/css/highlight.css @@ -1,4 +1,3 @@ - .o_list_renderer tr.o_data_row.selected_record td{ background-color: #7c7aad; color:#ffffff diff --git a/custom_list_view/static/src/js/duplicate_record.js b/custom_list_view/static/src/js/duplicate_record.js deleted file mode 100644 index 7e51cdb15..000000000 --- a/custom_list_view/static/src/js/duplicate_record.js +++ /dev/null @@ -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; - } -}); \ No newline at end of file diff --git a/custom_list_view/static/src/js/list_controller.js b/custom_list_view/static/src/js/list_controller.js new file mode 100644 index 000000000..45bd39e79 --- /dev/null +++ b/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 ", {}); + }); + }, +}); diff --git a/custom_list_view/static/src/js/list_renderer.js b/custom_list_view/static/src/js/list_renderer.js new file mode 100644 index 000000000..cc21711a1 --- /dev/null +++ b/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') + } + } +}); diff --git a/custom_list_view/static/src/js/record_highlight.js b/custom_list_view/static/src/js/record_highlight.js deleted file mode 100644 index 4e55d5fb7..000000000 --- a/custom_list_view/static/src/js/record_highlight.js +++ /dev/null @@ -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') - } - } -}) diff --git a/custom_list_view/static/src/xml/list_controller.xml b/custom_list_view/static/src/xml/list_controller.xml new file mode 100644 index 000000000..7b6dbd532 --- /dev/null +++ b/custom_list_view/static/src/xml/list_controller.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + +