server-tools icon indicating copy to clipboard operation
server-tools copied to clipboard

[18.0][MIG] excel_import_export: Migration to 18.0

Open xaviedoanhduy opened this issue 10 months ago • 9 comments

  • remove useless view_init in commit: https://github.com/odoo/odoo/pull/79563/commits/fbfbf1756b
  • fix domain (issue) on template_id field of import/export wizard. for some reason context is no longer present in python dynamic domains, see example here: https://github.com/odoo/odoo/pull/135145/commits/6828dd3489
  • user service is no longer a service, see: https://github.com/odoo/odoo/pull/145362/commits/ae660431

xaviedoanhduy avatar Feb 24 '25 10:02 xaviedoanhduy

Testing locally and here are some things I have noticed:

It looks like the export function works, though the files are created without the option to set a file name. Instead the files are named based on their file size. The more problematic issue is that the files are named without their extensions:

image

When opened the files seem to be correct but they cannot be used for imports: image

Error on trying to import file: image

wlin-kencove avatar Feb 24 '25 20:02 wlin-kencove

Manually adding .xlsx does not fix the import error

image image

wlin-kencove avatar Feb 24 '25 20:02 wlin-kencove

hi @wlin-kencove, fixed the above errors.

xaviedoanhduy avatar Feb 25 '25 04:02 xaviedoanhduy

The export looks good now, though the import is still displaying errors for me: image

I am using the file exported without editing it. I have it attached if it helps: S00001.xlsx

wlin-kencove avatar Feb 25 '25 15:02 wlin-kencove

image

This is what I am passing.

This is the error image

This is the file. S00001.xlsx

wlin-kencove avatar Feb 25 '25 16:02 wlin-kencove

hi @wlin-kencove, i found out where the problem is. the error is in the xlrd library in the new version (which is no longer available with .xlsx file type), see: https://github.com/python-excel/xlrd/blob/0c4e80b3d48dfe2250ac4e514c8231a742fee221/xlrd/init.py#L138

and i will try to make this module compatible with new version of xlrd, please be patient

xaviedoanhduy avatar Feb 26 '25 04:02 xaviedoanhduy

hi @wlin-kencove, i found out where the problem is. the error is in the xlrd library in the new version (which is no longer available with .xlsx file type), see: https://github.com/python-excel/xlrd/blob/0c4e80b3d48dfe2250ac4e514c8231a742fee221/xlrd/init.py#L138

and i will try to make this module compatible with new version of xlrd, please be patient

Ah I see, versions before 2.00 could read xlsx but afterwards it only reads xls. Our difference experiences must be due to the difference in versions. Maybe something like openpyxl could be a replacement?

wlin-kencove avatar Feb 26 '25 13:02 wlin-kencove

hi @wlin-kencove, i added some updates to fix import error with xlrd. can you check again?

xaviedoanhduy avatar Feb 28 '25 03:02 xaviedoanhduy

image

@xaviedoanhduy

Looks like that did it works for me now. Thanks for taking a look!

wlin-kencove avatar Feb 28 '25 20:02 wlin-kencove

@xaviedoanhduy : Test Case 1:

  • Try to update "account.move" record using following configuration("Settings > Technical > Excel Import/Export > XLSX Templates") using attached excel template file. 1

2

test_import_template.xlsx

  • Following error occurs when try to update "account.move" record("Accounting > Accounting > Journal Entries"): 3

4

test_import.xlsx

Test Case 2:

  • Try to update "account.move" records using following configuration("Settings > Technical > Excel Import/Export > XLSX Templates") using attached excel template file: 5

6

test_import_template_2.xlsx

  • Field not set properly when try to update "account.move" record("Accounting > Accounting > Journal Entries"): 7

8

9

test_import_2.xlsx

BhaveshHeliconia avatar Jun 16 '25 13:06 BhaveshHeliconia

ping @xaviedoanhduy

BhaveshHeliconia avatar Jun 24 '25 04:06 BhaveshHeliconia

hello @BhaveshHeliconia, I see your format and configuration looks quite strange, you can refer to my following sample based on the information you want to import

In Input Instruction (Dict.) page

  {
                '__EXPORT__': {
                    'Sheet1': {
                        '_HEAD_': {
                            'B1': 'ref',
                            'B2': 'date',
                        },
                        'line_ids': {
                            'A5': 'account_id.display_name',
                            'B5': 'partner_id.display_name',
                            'C5': 'name',
                            'D5': 'credit',
                            'E5': 'debit',
                        }
                    }
                },
                '__IMPORT__': {
                    'Sheet1': {
                        '_HEAD_': {
                            'B1': 'ref',
                            'B2': 'date',
                        },
                        '_NODEL_line_ids': {
                           'A5': 'account_id',
                            'B5': 'partner_id',
                            'C5': 'name',
                            'D5': 'credit',
                            'E5': 'debit',
                        }
                    }
                },
                # '__POST_IMPORT__': '${object.post_import_do_something()}',
            }

the file content should be: image

xaviedoanhduy avatar Jun 25 '25 12:06 xaviedoanhduy

input file should like this image

xaviedoanhduy avatar Jun 25 '25 12:06 xaviedoanhduy

@xaviedoanhduy : I've tried to import with the sample described by you, but still it's not working. I've attached video showing steps I've performed and error and also attached excel files I've used in this video.

https://github.com/user-attachments/assets/c816f7fe-8737-4e49-ad70-6160b3254066

BhaveshHeliconia avatar Jul 07 '25 07:07 BhaveshHeliconia

@BhaveshHeliconia, do you have the same problem locally but on a different version? FYI, i checked on runboat and everything is working

image

xaviedoanhduy avatar Jul 09 '25 07:07 xaviedoanhduy

@xaviedoanhduy : It's working fine now. I think it was missing this commit: https://github.com/OCA/server-tools/pull/3207/commits/fbbf238e70edb996901f60254ae8c345b54bc8d2

BhaveshHeliconia avatar Jul 14 '25 05:07 BhaveshHeliconia

Functional test LGTM!!

BhaveshHeliconia avatar Jul 14 '25 05:07 BhaveshHeliconia

@OCA/tools-maintainers Please, can you merge this PR?

Reyes4711-S73 avatar Nov 06 '25 16:11 Reyes4711-S73

/ocabot merge nobump

thomaspaulb avatar Nov 06 '25 20:11 thomaspaulb

Hey, thanks for contributing! Proceeding to merge this for you. Prepared branch 18.0-ocabot-merge-pr-3207-by-thomaspaulb-bump-nobump, awaiting test results.

OCA-git-bot avatar Nov 06 '25 20:11 OCA-git-bot

Congratulations, your PR was merged at e40eeb5a4928ced98c107a9a4225ed1d4dfa5ba8. Thanks a lot for contributing to OCA. ❤️

OCA-git-bot avatar Nov 06 '25 20:11 OCA-git-bot