Closed victoralmau closed 3 weeks ago
Ping @carolinafernandez-tecnativa and @pilarvargas-tecnativa
Just a little suggestion for multi company templates:
1 - Configure one template for My Company (San Francisco) 2- Change to company My Company Chicago and tried to import PDF for the template configured in step 1. 3- I got this error message:
I think it has to show a message like this "No template found for this PDF" or redirect to Documents genereted with empty list.
During the functional review, if I leave the pattern field empty, this error appears: Traceback (most recent call last): File "/opt/odoo/odoo/addons/base/models/ir_http.py", line 242, in _dispatch result = request.dispatch() File "/opt/odoo/odoo/http.py", line 702, in dispatch result = self._call_function(self.params) File "/opt/odoo/odoo/http.py", line 368, in _call_function return checked_call(self.db, *args, *kwargs) File "/opt/odoo/odoo/service/model.py", line 94, in wrapper return f(dbname, args, kwargs) File "/opt/odoo/odoo/http.py", line 357, in checked_call result = self.endpoint(*a, kw) File "/opt/odoo/odoo/http.py", line 925, in call return self.method(*args, *kw) File "/opt/odoo/odoo/http.py", line 546, in response_wrap response = f(args, kw) File "/opt/odoo/addons/web/controllers/main.py", line 1328, in call_button action = self._call_kw(model, method, args, kwargs) File "/opt/odoo/addons/web/controllers/main.py", line 1316, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/opt/odoo/odoo/api.py", line 471, in call_kw result = _call_kw_multi(method, model, args, kwargs) File "/opt/odoo/odoo/api.py", line 456, in _call_kw_multi result = method(recs, *args, **kwargs) File "/mnt/data/odoo-addons-dir/base_import_pdf_simple/wizards/wizard_base_import_pdf_upload.py", line 62, in action_process records += line.action_process() File "/mnt/data/odoo-addons-dir/base_import_pdf_simple/wizards/wizard_base_import_pdf_upload.py", line 121, in action_process record = self._process_form() File "/mnt/data/odoo-addons-dir/base_import_pdf_simple/wizards/wizard_base_import_pdf_upload.py", line 188, in _process_form table_info = template._get_table_info(text) File "/mnt/data/odoo-addons-dir/base_import_pdf_simple/models/base_import_pdf_template.py", line 92, in _get_table_info data = self._get_table_info_data(text) File "/mnt/data/odoo-addons-dir/base_import_pdf_simple/models/base_import_pdf_template.py", line 114, in _get_table_info_data data_key_0 = data_keys[0] Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/opt/odoo/odoo/http.py", line 658, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/opt/odoo/odoo/http.py", line 301, in _handle_exception raise exception.with_traceback(None) from new_cause IndexError: list index out of range
I assume that the pattern should be required when the line is a variable type to avoid this error. Thank you.
During the functional review, if I leave the pattern field empty, this error appears: Traceback (most recent call last): File "/opt/odoo/odoo/addons/base/models/ir_http.py", line 242, in _dispatch result = request.dispatch() File "/opt/odoo/odoo/http.py", line 702, in dispatch result = self._call_function(self.params) File "/opt/odoo/odoo/http.py", line 368, in _call_function return checked_call(self.db, *args, *kwargs) File "/opt/odoo/odoo/service/model.py", line 94, in wrapper return f(dbname, args, kwargs) File "/opt/odoo/odoo/http.py", line 357, in checked_call result = self.endpoint(*a, kw) File "/opt/odoo/odoo/http.py", line 925, in call return self.method(*args, *kw) File "/opt/odoo/odoo/http.py", line 546, in response_wrap response = f(args, kw) File "/opt/odoo/addons/web/controllers/main.py", line 1328, in call_button action = self._call_kw(model, method, args, kwargs) File "/opt/odoo/addons/web/controllers/main.py", line 1316, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/opt/odoo/odoo/api.py", line 471, in call_kw result = _call_kw_multi(method, model, args, kwargs) File "/opt/odoo/odoo/api.py", line 456, in _call_kw_multi result = method(recs, *args, **kwargs) File "/mnt/data/odoo-addons-dir/base_import_pdf_simple/wizards/wizard_base_import_pdf_upload.py", line 62, in action_process records += line.action_process() File "/mnt/data/odoo-addons-dir/base_import_pdf_simple/wizards/wizard_base_import_pdf_upload.py", line 121, in action_process record = self._process_form() File "/mnt/data/odoo-addons-dir/base_import_pdf_simple/wizards/wizard_base_import_pdf_upload.py", line 188, in _process_form table_info = template._get_table_info(text) File "/mnt/data/odoo-addons-dir/base_import_pdf_simple/models/base_import_pdf_template.py", line 92, in _get_table_info data = self._get_table_info_data(text) File "/mnt/data/odoo-addons-dir/base_import_pdf_simple/models/base_import_pdf_template.py", line 114, in _get_table_info_data data_key_0 = data_keys[0] Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/opt/odoo/odoo/http.py", line 658, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/opt/odoo/odoo/http.py", line 301, in _handle_exception raise exception.with_traceback(None) from new_cause IndexError: list index out of range
I assume that the pattern should be required when the line is a variable type to avoid this error. Thank you.
When you got that error message it means something is not well configured. Go to Settings > Technical > Base Import PDF Simple > Templates and in the template you defined, you have a button called Preview. Press button Preview and upload your file. In "Technical information" you will see if the information is correctly extracted from PDF. Otherwise, you need to modify PDF Template until you get all the information set in template.
Maybe the pattern field should be required / have a sane default.
Maybe the pattern field should be required / have a sane default.
Yes it is something we could add as an improvement, but it won't solve the error message. As this error could appear because Pattern is not established correctly or Columns added on lines not set correctly. I think what we can do additionally, is to catch the exception and got an User error "Please check template defined, some items are not correctly set" (as an example of error message)
Yes, good idea.
Changes done: Pattern defined as invisible/required and improvement added to ROADMAP.
After last changes I got this error message when trying to import pdf on purchase order:
I put the same configuration as previous test and when preview, fields are getting correctly.
What a great day to merge this nice PR. Let's do it! Prepared branch 15.0-ocabot-merge-pr-964-by-pedrobaeza-bump-nobump, awaiting test results.
Congratulations, your PR was merged at 30604c8a18f640c64f8a53cea2125cf310cb3a91. Thanks a lot for contributing to OCA. ❤️
New module
Example use case (import a PDF in Contacts)
![ejemplo-import](https://github.com/OCA/edi/assets/4117568/7bd9ea22-6c64-45ce-a60a-565bae38590d)
Other use cases: Sale Orders, Purchase Orders, Invoices, etc
TODO:
@Tecnativa TT48213