Browse Source

: Dec 04: [FIX] Bug Fixed 'instant_import'

pull/331/merge
Risvana Cybro 3 weeks ago
parent
commit
2a5051740b
  1. BIN
      instant_import/.DS_Store
  2. 61
      instant_import/README.md
  3. 47
      instant_import/README.rst
  4. 2
      instant_import/__init__.py
  5. 36
      instant_import/__manifest__.py
  6. 6
      instant_import/doc/RELEASE_NOTES.md
  7. 82
      instant_import/hooks.py
  8. 0
      instant_import/static/description/assets/h2.png
  9. BIN
      instant_import/static/description/assets/modules/b1.png
  10. BIN
      instant_import/static/description/assets/modules/b2.png
  11. BIN
      instant_import/static/description/assets/modules/b3.png
  12. BIN
      instant_import/static/description/assets/modules/b4.png
  13. BIN
      instant_import/static/description/assets/modules/b5.png
  14. BIN
      instant_import/static/description/assets/modules/b6.png
  15. BIN
      instant_import/static/description/assets/screenshots/instant_import_01.png
  16. BIN
      instant_import/static/description/assets/screenshots/instant_import_02.png
  17. BIN
      instant_import/static/description/assets/screenshots/instant_import_03.png
  18. BIN
      instant_import/static/description/assets/screenshots/instant_import_04.png
  19. BIN
      instant_import/static/description/assets/screenshots/instant_import_05.png
  20. BIN
      instant_import/static/description/assets/screenshots/instant_import_06.png
  21. 0
      instant_import/static/description/assets/y18.jpg
  22. 28
      instant_import/static/description/index.html
  23. 70
      instant_import/static/src/js/import_component.js
  24. 4
      instant_import/static/src/js/instant_import.js
  25. 3
      instant_import/wizard/__init__.py
  26. 2045
      instant_import/wizard/import_wizard.py

BIN
instant_import/.DS_Store

Binary file not shown.

61
instant_import/README.md

@ -19,6 +19,7 @@ volumes of data are imported quickly and efficiently.
- **Real-Time Validation**: Instantly checks for field mismatches or errors before importing. - **Real-Time Validation**: Instantly checks for field mismatches or errors before importing.
- **OWL-Based Interface**: Modern and responsive UI built with Odoo Web Library (OWL) for smooth user experience. - **OWL-Based Interface**: Modern and responsive UI built with Odoo Web Library (OWL) for smooth user experience.
- **Seamless Record Creation**: Automatically creates records without navigating away from the current view. - **Seamless Record Creation**: Automatically creates records without navigating away from the current view.
-
## Screenshots ## Screenshots
Here are some glimpses of Odoo Instant Import: Here are some glimpses of Odoo Instant Import:
@ -73,3 +74,63 @@ Here are some glimpses of Odoo Instant Import:
Before you begin, ensure you have the following installed: Before you begin, ensure you have the following installed:
- An active Odoo Community/Enterprise Edition instance (local or hosted) - An active Odoo Community/Enterprise Edition instance (local or hosted)
## Installation
Follow these steps to set up and run the app:
1. **Clone the Repository**
```git clone https://github.com/cybrosystech/Instant-Import.git```
2. **Add the module to addons**
```cd Instant-Import```
## Contributing
The feature - The ability to update existing records during import is not yet implemented.
Currently, the importer supports only the creation of new records.
Updates to existing entries will be available in a future release.
We welcome contributions! To get started:
1. Fork the repository.
2. Create a new branch:
```
git checkout -b feature/your-feature-name
```
3. Make changes and commit:
```
git commit -m "Add your message here"
```
4. Push your changes:
```
git push origin feature/your-feature-name
```
5. Create a Pull Request on GitHub.
---
- Submit a pull request with a clear description of your changes.
## License
This project is licensed under the LGPL-3. Feel free to use, modify, and distribute it as needed.
Company
-------
* `Cybrosys Techno Solutions <https://cybrosys.com/>`
## Contact
* Mail Contact : odoo@cybrosys.com
* Website : https://cybrosys.com
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 https://www.cybrosys.com

47
instant_import/README.rst

@ -0,0 +1,47 @@
.. 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
Instant Import Odoo 17
===========================
Instant import for odoo 17
Configuration
=============
No additional configurations needed.
Company
-------
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__
License
-------
Lesser General Public License, Version 3 (LGPL v3)
(https://www.gnu.org/licenses/lgpl-3.0-standalone.html)
Credits
-------
* Developer : (V17) Muhammed Fahis VP, Vaishnav MV
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 <https://cybrosys.com/>`__
Further information
===================
HTML Description: `<static/description/index.html>`__

2
instant_import/__init__.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- # -- coding: utf-8 --
############################################################################# #############################################################################
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.

36
instant_import/__manifest__.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- # -- coding: utf-8 --
############################################################################# #############################################################################
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
@ -22,29 +22,29 @@
{ {
'name': 'Instant Import', 'name': 'Instant Import',
'version': '17.0.1.0.0', 'version': '17.0.1.0.0',
'depends': ['base', 'web', 'base_import'],
'category': 'Tools', 'category': 'Tools',
'summary': 'Module for fast bulk imports using PostgreSQL COPY', 'summary': 'Module for fast bulk imports using PostgreSQL COPY',
'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',
'application': False, 'depends': ['base', 'web', 'base_import'],
'data': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',
],
'assets': {
'web.assets_backend': [
'instant_import/static/src/js/import_component.js',
'instant_import/static/src/js/import_component.xml',
'instant_import/static/src/js/instant_import.js',
'instant_import/static/src/js/templates.xml',
], ],
}, 'assets': {
'images': [ 'web.assets_backend': [
'static/description/banner.jpg', 'instant_import/static/src/js/import_component.js',
], 'instant_import/static/src/js/import_component.xml',
'instant_import/static/src/js/instant_import.js',
'instant_import/static/src/js/templates.xml',
],
},
'images': ['static/description/banner.jpg'],
'license': 'LGPL-3', 'license': 'LGPL-3',
'installable': True,
'auto_install': False,
'application': True,
'post_init_hook': 'setup_db_level_functions', 'post_init_hook': 'setup_db_level_functions',
'uninstall_hook': 'delete_contact', 'uninstall_hook': 'delete_contact',
} }

6
instant_import/doc/RELEASE_NOTES.md

@ -1,7 +1,7 @@
## Module <custom_import> ## Module <instant_import>
#### 17.07.2025 #### 17.09.2025
#### Version 17.0.1.0.0 #### Version 17.0.1.0.0
##### ADD ##### ADD
- Initial Commit for Custom Import - Initial Commit for Instant Import

82
instant_import/hooks.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- # -- coding: utf-8 --
############################################################################# #############################################################################
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
@ -126,9 +126,87 @@ def setup_db_level_functions(env):
""" """
) )
env.cr.execute(
"""
CREATE OR REPLACE FUNCTION process_o2m_mapping()
RETURNS TRIGGER AS $$
DECLARE
values json;
field_name TEXT;
field_config json;
record_data json;
field_value text;
column_info record;
column_list text;
value_list text;
debug_msg text;
BEGIN
values := TG_ARGV[0]::json;
FOR field_name, field_config IN SELECT * FROM json_each(values::json) LOOP
EXECUTE format('SELECT ($1).%I::text', field_name)
INTO field_value
USING NEW;
IF field_value IS NOT NULL THEN
FOR record_data IN SELECT * FROM json_array_elements(field_value::json) LOOP
-- Log the record data for debugging
RAISE NOTICE 'Record data: %', record_data;
SELECT
string_agg(quote_ident(c.column_name), ', '),
string_agg(
CASE
WHEN c.data_type IN ('integer', 'bigint') THEN format('CAST(($2->>%L) AS INTEGER)', c.column_name)
WHEN c.data_type = 'numeric' THEN format('CAST(($2->>%L) AS NUMERIC)', c.column_name)
WHEN c.data_type = 'double precision' THEN format('CAST(($2->>%L) AS DOUBLE PRECISION)', c.column_name)
WHEN c.data_type = 'boolean' THEN format('CAST(($2->>%L) AS BOOLEAN)', c.column_name)
WHEN c.data_type = 'date' THEN format('CAST(($2->>%L) AS DATE)', c.column_name)
-- FIXED: Handle all timestamp variations
WHEN c.data_type IN ('timestamp without time zone', 'timestamp with time zone')
THEN format('CAST(($2->>%L) AS TIMESTAMP)', c.column_name)
WHEN c.data_type = 'datetime' THEN format('CAST(($2->>%L) AS TIMESTAMP)', c.column_name)
ELSE format('$2->>%L', c.column_name)
END,
', '
)
INTO
column_list,
value_list
FROM information_schema.columns c
WHERE c.table_name = field_config->>'data_table'
AND c.column_name = ANY (
ARRAY(SELECT key::text FROM json_object_keys(record_data) AS t(key))
);
-- Add the inverse_name column and value
column_list := quote_ident(field_config->>'inverse_name') || ', ' || COALESCE(column_list, '');
value_list := '$1, ' || COALESCE(value_list, '');
-- Build the complete SQL statement
debug_msg := format(
'INSERT INTO %I (%s) VALUES (%s)',
field_config->>'data_table',
column_list,
value_list
);
EXECUTE debug_msg
USING NEW.id, record_data;
END LOOP;
END IF;
END LOOP;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
"""
)
def delete_contact(env): def delete_contact(env):
env.cr.execute( env.cr.execute(
""" """
DROP FUNCTION IF EXISTS process_m2m_mapping(); DROP FUNCTION IF EXISTS process_m2m_mapping();
DROP FUNCTION IF EXISTS process_o2m_mapping();
""" """
) )

0
instant_import/static/description/assets/h2.png

Before

Width:  |  Height:  |  Size: 628 KiB

After

Width:  |  Height:  |  Size: 628 KiB

BIN
instant_import/static/description/assets/modules/b1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 84 KiB

BIN
instant_import/static/description/assets/modules/b2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 86 KiB

BIN
instant_import/static/description/assets/modules/b3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 KiB

After

Width:  |  Height:  |  Size: 47 KiB

BIN
instant_import/static/description/assets/modules/b4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 44 KiB

BIN
instant_import/static/description/assets/modules/b5.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 107 KiB

BIN
instant_import/static/description/assets/modules/b6.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 80 KiB

BIN
instant_import/static/description/assets/screenshots/instant_import_01.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 KiB

After

Width:  |  Height:  |  Size: 288 KiB

BIN
instant_import/static/description/assets/screenshots/instant_import_02.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 KiB

After

Width:  |  Height:  |  Size: 529 KiB

BIN
instant_import/static/description/assets/screenshots/instant_import_03.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 147 KiB

BIN
instant_import/static/description/assets/screenshots/instant_import_04.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 143 KiB

BIN
instant_import/static/description/assets/screenshots/instant_import_05.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 214 KiB

BIN
instant_import/static/description/assets/screenshots/instant_import_06.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 KiB

After

Width:  |  Height:  |  Size: 267 KiB

0
instant_import/static/description/assets/y18.jpg

Before

Width:  |  Height:  |  Size: 880 KiB

After

Width:  |  Height:  |  Size: 880 KiB

28
instant_import/static/description/index.html

@ -172,7 +172,29 @@
>Email Us</span >Email Us</span
> >
</a> </a>
<a href="skype:cybroopenerp?chat"
target="_blank"
style="
background-color: #7f289b;
font-family: Montserrat;
display: inline-block;
padding: 7px 33px;
border: 1px solid #7f289b;
border-radius: 35px;
text-decoration: none;
"
class="mx-1 mb-2 deep-1 deep_hover">
<img
class="img"
style="width: 24px"
src="./assets/icons/skype-fill.svg"
/>
<span
class="pl-2"
style="color: #fff; font-size: 16px; vertical-align: middle"
>Skype Us</span
>
</a>
</div> </div>
<div class="d-flex justify-content-center mt-2"> <div class="d-flex justify-content-center mt-2">
<img src="./assets/screenshots/Gif.gif" <img src="./assets/screenshots/Gif.gif"
@ -385,7 +407,7 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h1 style="font-weight:bold; font-size:calc(1.1rem + 1vw); line-height:120%; text-align:center; text-transform:capitalize; font-size:40px; font-weight:700;"> <h1 style="font-weight:bold; font-size:calc(1.1rem + 1vw); line-height:120%; text-align:center; text-transform:capitalize; font-size:40px; font-weight:700;">
<span style="color:#121212; font-size:calc(1.1rem + 1vw)">Click on the action button in the view then click on the Instant import menu</span> <span style="color:#121212; font-size:calc(1.1rem + 1vw)">Click on the action button in the view</span>
</h1> </h1>
</div> </div>
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
@ -546,7 +568,7 @@
style="color:#fff; font-size:14px"></i> style="color:#fff; font-size:14px"></i>
</div> </div>
<p style="color:#1A202C; font-weight:600; font-size:1.2rem; margin-bottom:2px"> <p style="color:#1A202C; font-weight:600; font-size:1.2rem; margin-bottom:2px">
Ensures clean and consistent import for Many2one and Many2many relational fields. Ensures clean and consistent import for Many2one, One2many and Many2many relational fields.
</p> </p>
</div> </div>

70
instant_import/static/src/js/import_component.js

@ -1,5 +1,4 @@
/** @odoo-module **/ /** @odoo-module **/
import { registry } from "@web/core/registry"; import { registry } from "@web/core/registry";
import { ImportAction } from "@base_import/import_action/import_action"; import { ImportAction } from "@base_import/import_action/import_action";
import { useService } from "@web/core/utils/hooks"; import { useService } from "@web/core/utils/hooks";
@ -22,8 +21,6 @@ export class InstantImport extends ImportAction {
this.blockUI.block({ this.blockUI.block({
message: "Your records are being imported...", message: "Your records are being imported...",
}); });
console.log("Importing model:", this.props.action.params.model);
const result = await this.orm.call( const result = await this.orm.call(
"custom.import.wizard", "custom.import.wizard",
"copy_import", "copy_import",
@ -47,7 +44,6 @@ export class InstantImport extends ImportAction {
} }
} catch (error) { } catch (error) {
console.error("Import error:", error);
// Extract the actual error message from the error object // Extract the actual error message from the error object
let errorMessage = "Import failed. Please check your data."; let errorMessage = "Import failed. Please check your data.";
@ -84,7 +80,6 @@ export class InstantImport extends ImportAction {
{} {}
); );
console.log('Validation result:', validationResult);
if (validationResult && validationResult.is_valid) { if (validationResult && validationResult.is_valid) {
this.notification.add(`Everything seems valid`, { this.notification.add(`Everything seems valid`, {
@ -112,7 +107,6 @@ export class InstantImport extends ImportAction {
} }
} catch (error) { } catch (error) {
console.error("Error during column validation:", error);
// Extract the actual error message from the error object // Extract the actual error message from the error object
let errorMessage = "Validation failed. Please check your data."; let errorMessage = "Validation failed. Please check your data.";
@ -135,4 +129,66 @@ export class InstantImport extends ImportAction {
} }
} }
registry.category("actions").add("instant_import", InstantImport); registry.category("actions").add("instant_import", InstantImport);
///** @odoo-module **/
//
//import { registry } from "@web/core/registry";
//import { ImportAction } from "@base_import/import_action/import_action";
//import { useService } from "@web/core/utils/hooks";
//import { BlockUI } from "@web/core/ui/block_ui";
//
//export class CustomImport extends ImportAction {
// static template = "custom_import.importaction";
// static components = { ...ImportAction.components, BlockUI };
//
// setup() {
// super.setup();
// this.orm = useService('orm');
// this.action = useService('action');
// this.notification = useService("notification");
// this.blockUI = useService("ui");
// }
//
// async handleImport() {
// try {
// this.blockUI.block({
// message: "Your records are being imported...",
// });
//
// const result = await this.orm.call(
// "custom.import.wizard",
// "copy_import",
// [this.model.id, this.props.action.params.model, this.model.columns],
// {}
// );
//
// if (result && result.record_count) {
// this.notification.add(` ${result.record_count} Records successfully imported`, {
// type: "success",
// });
// }
//
// this.action.doAction({
// type: "ir.actions.act_window",
// res_model: this.props.action.params.model,
// name: result.name,
// views: [[false, 'kanban'], [false, 'form']],
// target: 'main',
// });
// }finally {
// this.blockUI.unblock();
// }
// }
//}
//registry.category("actions").add("custom_import", CustomImport);

4
instant_import/static/src/js/instant_import.js

@ -1,9 +1,5 @@
/** @odoo-module **/ /** @odoo-module **/
import { DropdownItem } from "@web/core/dropdown/dropdown_item";
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks"; import { useService } from "@web/core/utils/hooks";
import { Component } from "@odoo/owl";
import { patch } from "@web/core/utils/patch"; import { patch } from "@web/core/utils/patch";
import { ImportRecords } from "@base_import/import_records/import_records"; import { ImportRecords } from "@base_import/import_records/import_records";

3
instant_import/wizard/__init__.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- # -- coding: utf-8 --
############################################################################# #############################################################################
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
@ -20,4 +20,3 @@
# #
############################################################################# #############################################################################
from . import import_wizard from . import import_wizard

2045
instant_import/wizard/import_wizard.py

File diff suppressed because it is too large
Loading…
Cancel
Save