Browse Source

:Dec 15 [UPDT] Feature Updated 'instant_import'

17.0
Risvana Cybro 1 day ago
parent
commit
62532f70d6
  1. 28
      instant_import/hooks.py
  2. 47
      instant_import/static/description/index.html
  3. 1968
      instant_import/wizard/import_wizard.py

28
instant_import/hooks.py

@ -22,7 +22,7 @@
def setup_db_level_functions(env):
env.cr.execute(
"""
CREATE OR REPLACE FUNCTION process_m2m_mapping()
CREATE OR REPLACE FUNCTION process_m2m_mapping()
RETURNS TRIGGER AS $$
DECLARE
col record;
@ -35,7 +35,7 @@ def setup_db_level_functions(env):
column_type text;
field_config jsonb;
BEGIN
-- Get the mapping configuration from TG_ARGV[0]
-- Get the mapping configuration from TG_ARGV[0]
-- Expected format:
-- {
-- "m2m__field1": {"data_table": "table1", "mapping_table": "map1", "column1": "col1", "column2": "col2"},
@ -45,8 +45,8 @@ def setup_db_level_functions(env):
-- Loop through all columns of the table
FOR col IN (
SELECT column_name
FROM information_schema.columns
SELECT column_name
FROM information_schema.columns
WHERE table_name = TG_TABLE_NAME::text
AND column_name LIKE 'm2m__%'
) LOOP
@ -62,9 +62,9 @@ def setup_db_level_functions(env):
-- Get the data type of the name column
EXECUTE format(
'SELECT data_type
FROM information_schema.columns
WHERE table_name = %L
'SELECT data_type
FROM information_schema.columns
WHERE table_name = %L
AND column_name = ''name''',
field_config->>'data_table'
) INTO column_type;
@ -104,8 +104,8 @@ def setup_db_level_functions(env):
-- Insert into mapping table if both IDs are found
IF id1 IS NOT NULL AND id2 IS NOT NULL THEN
EXECUTE format(
'INSERT INTO %I (%I, %I)
VALUES (%L, %L)
'INSERT INTO %I (%I, %I)
VALUES (%L, %L)
ON CONFLICT (%I, %I) DO NOTHING',
field_config->>'mapping_table',
field_config->>'column1',
@ -153,24 +153,24 @@ def setup_db_level_functions(env):
-- Log the record data for debugging
RAISE NOTICE 'Record data: %', record_data;
SELECT
SELECT
string_agg(quote_ident(c.column_name), ', '),
string_agg(
CASE
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')
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,
END,
', '
)
INTO
INTO
column_list,
value_list
FROM information_schema.columns c

47
instant_import/static/description/index.html

@ -169,7 +169,7 @@
<span
class="pl-2"
style=" font-size: 16px; vertical-align: middle"
>Email Us</span
>Email Us</span
>
</a>
<a href="skype:cybroopenerp?chat"
@ -212,6 +212,44 @@
<img src="./assets/icons/patter.svg">
</div>
</div>
<section class="oe_container">
<div class="mt64 mb64">
<div class="col-sm-12 py-4">
<div class="alert alert-primary mt-4"
style="color: #000;background-color: #f8f8f8;border: 1px solid #dcdcdc;border-radius: 16px;">
This module uses some external python dependencies :
pandas. Before
installing the module install the python
package
first. The required python packages can be installed using the
following commands.
<br>
<br/>
<code class="d-block mt-2"
style="background-color:#4e4e4e;color: #fff;padding: 6px 8px; border-radius: 5px;">pip
install pandas</code>
<br>
<br/>
For smoother performance during limit handling and bulk imports, you may optionally
increase processing time in <span><b>odoo.conf</b></span> by adjusting <span><b>limit_time_cpu</b></span>
and <span><b>limit_time_real</b></span>.
<br>
<code class="d-block mt-2"
style="background-color:#4e4e4e;color: #fff; border-radius: 5px; padding: 6px 8px;">limit_time_cpu
= 600<br>
limit_time_real = 9999<br/>
</code><br>
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.
</div>
</div>
</div>
</section>
<!-- key-highlight -->
<div class="" style="border-radius: 16px;
padding: 60px 40px;
@ -568,7 +606,8 @@
style="color:#fff; font-size:14px"></i>
</div>
<p style="color:#1A202C; font-weight:600; font-size:1.2rem; margin-bottom:2px">
Ensures clean and consistent import for Many2one, One2many and Many2many relational fields.
Ensures clean and consistent import for Many2one, One2many and Many2many
relational fields.
</p>
</div>
@ -885,7 +924,9 @@
</div>
</a>
</div>
</div></section></div>
</div>
</section>
</div>
<!-- licence -->
<div class="tab-pane fade" id="profile" role="tabpanel"
aria-labelledby="profile-tab">

1968
instant_import/wizard/import_wizard.py

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