Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][ADD] account_edi_simple_pdf #959

Draft
wants to merge 72 commits into
base: 15.0
Choose a base branch
from

Conversation

hbrunn
Copy link
Member

@hbrunn hbrunn commented Mar 29, 2024

this is account_invoice_import_simple_pdf but then plugged into Odoo's existing invoice import mechanism.

Missing:

  • amend invoices by upload
  • cleanup/refactor if we go for 2. below

I've started this as a spiritual successor of account_invoice_import_simple_pdf, that's why I preserved the commits, and prepared for possibly having both - we'd have to move the configuration and the mixin to its own module on which both depend and just apply the mixin. But now I'm unsure, as those functionalities conflict, so coexistence doesn't really seem an option to me.

What do reviewers think?

  1. keep history, this will cause problems for a migration of account_invoice_import_simple_pdf
  2. remove history, don't try to be compatible with a future account_invoice_import_simple_pdf migration

@hbrunn hbrunn marked this pull request as draft March 29, 2024 17:41
@pedrobaeza
Copy link
Member

@hbrunn check this that we are cooking that is very generic for any possible document: https://github.com/Tecnativa/edi/tree/15.0-add-base_import_pdf_simple/base_import_pdf_simple

We have started it for importing sales orders, but it can serve for anything

We'll propose it to OCA soon.

@hbrunn
Copy link
Member Author

hbrunn commented Mar 30, 2024

oh that looks interesting, thanks. The readme is hard to read for me though ;-)

Thing is, @alexis-via's code is time proven and my customer is used to it, they just want to have that in their v15 instance too. And rather now than soon. I don't see a problem having account_edi_simple_pdf now and a possible import_pdf_simple_account_move (what will this depend on? account_edi or account_invoice_import?) next to each other here. Maybe a word or two about the differences between them might be helpful when we've come so far.

We do already keep the account_import* stack and the parallel facturx import here, so more choice, the merrier I'd say. Actually for facturx a comparison in the repo's/module's readme would be very helpful too, I can't tell a customer from the top off my head why they should use the OCA version instead of the core one.

@alexis-via what's your take on keeping the history here? And would you prefer me to disentangle this completely from account_invoice_import_simple_pdf whenever this lands in v15, or prepare for sharing most of the code?

@pedrobaeza
Copy link
Member

The problem with existing *_simple_import* module is that it doesn't handle properly multi-lines import with all the needed fields. We have already tackled this in a generic way to serve to import sales order, purchase orders, invoices...

@jans23
Copy link

jans23 commented May 14, 2024

Is this used by the ordinary Upload button?

grafik

@hbrunn
Copy link
Member Author

hbrunn commented May 14, 2024

yes, watch your logs for messages about recognizing a partner, and further messages

@pedrobaeza
Copy link
Member

Another approach to try is #964

The fetchmail/import gateway is very simple to be added.

@jans23
Copy link

jans23 commented May 16, 2024

When trying the test upload within Contact's tab "Vendor Bill Import" I get the following error while when trying to import the same invoice within Invoicing -> Vendors -> Bills, Upload button I get useful messages such as "Missing invoice number format configuration on partner". For me this makes the test upload functionality useless.

RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
  File "/srv/odoo/odoo/parts/odoo/odoo/addons/base/models/ir_http.py", line 242, in _dispatch
    result = request.dispatch()
  File "/srv/odoo/odoo/parts/odoo/odoo/http.py", line 702, in dispatch
    result = self._call_function(**self.params)
  File "/srv/odoo/odoo/parts/odoo/odoo/http.py", line 368, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/srv/odoo/odoo/parts/odoo/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/srv/odoo/odoo/parts/odoo/odoo/http.py", line 357, in checked_call
    result = self.endpoint(*a, **kw)
  File "/srv/odoo/odoo/parts/odoo/odoo/http.py", line 925, in __call__
    return self.method(*args, **kw)
  File "/srv/odoo/odoo/parts/odoo/odoo/http.py", line 546, in response_wrap
    response = f(*args, **kw)
  File "/tmp/addons/web/controllers/main.py", line 1328, in call_button
    action = self._call_kw(model, method, args, kwargs)
  File "/tmp/addons/web/controllers/main.py", line 1316, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/srv/odoo/odoo/parts/odoo/odoo/api.py", line 471, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/srv/odoo/odoo/parts/odoo/odoo/api.py", line 456, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/tmp/addons/account_edi_simple_pdf/models/res_partner.py", line 194, in pdf_simple_test_run
    aiio = self.env["account.invoice.import"]
  File "/srv/odoo/odoo/parts/odoo/odoo/api.py", line 553, in __getitem__
    return self.registry[model_name]._browse(self, (), ())
  File "/srv/odoo/odoo/parts/odoo/odoo/modules/registry.py", line 182, in __getitem__
    return self.models[model_name]
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/srv/odoo/odoo/parts/odoo/odoo/http.py", line 658, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/srv/odoo/odoo/parts/odoo/odoo/http.py", line 301, in _handle_exception
    raise exception.with_traceback(None) from new_cause
KeyError: 'account.invoice.import'

@jans23
Copy link

jans23 commented May 24, 2024

account_invoice_import_simple_pdf allows to define Invoice Import Configurations. I don't find such option with this module. Where can I find it or is it obsolete? I want to define the vendor's account.

grafik

@hbrunn
Copy link
Member Author

hbrunn commented May 24, 2024

@jans23 thanks for your input. Note however that this is a draft and not really ready for review, even though it (mostly) works for my customer already the way they need it to. I mainly wanted to start a discussion about the future of invoice import in Odoo/OCA.

Regarding your question about import configurations: That's part of the account_invoice_import framework which is migrated in #668 but stalled for quite a while. So won't happen here. I can however imagine adding a product to use for the one imported line per invoice on the partner form, to allow custom accounts/taxes per partner.

alexis-via and others added 16 commits November 22, 2024 10:40
This new module is an improved alternative to the module account_invoice_import_invoice2data. Refer to README for more information.
…urences of cut string

Add tests on string cut method
Before this fix, Page Analysis was always "First page" in the code.
FIX on view inheritance to avoid access right issues
Support combining accent letters
Support bad accent extraction of mupdf on invoices such as Free mobile
Use getattr to find the method which parses a particular field, as
suggested by Graeme Gellatly
…sition_max

Add list of fields on search_read() to improve perf
alexis-via and others added 29 commits November 22, 2024 10:40
Add a hook to easily inherit the module
account_invoice_import_simple_pdf to match partners on fields other than
"vat". For example, the module l10n_fr_account_invoice_import_simple_pdf
takes advantage of this hook to match partners on SIREN (French
identification number for companies).
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: edi-14.0/edi-14.0-account_invoice_import_simple_pdf
Translate-URL: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-account_invoice_import_simple_pdf/
Currently translated at 100.0% (145 of 145 strings)

Translation: edi-14.0/edi-14.0-account_invoice_import_simple_pdf
Translate-URL: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-account_invoice_import_simple_pdf/fr/
Issue reported here OCA#544 is fixed in recent version of dateparser
Add pypdf text extraction backend
Update README for pypdf, and also for the fact that PyMuPDF is now easy to install
Remove embedded XML file from PDF test file tests/pdf/akretion_france-test.pdf !
Currently translated at 77.9% (113 of 145 strings)

Translation: edi-14.0/edi-14.0-account_invoice_import_simple_pdf
Translate-URL: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-account_invoice_import_simple_pdf/es/
Currently translated at 100.0% (145 of 145 strings)

Translation: edi-14.0/edi-14.0-account_invoice_import_simple_pdf
Translate-URL: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-account_invoice_import_simple_pdf/es/
pdfplumber depends on Pillow >= 9.1, whereas Odoo v14 depends on
Pillow==8.1.1. This causes python dependency issues. So, to make it
easier to deploy the module account_invoice_import_simple_pdf, I decided
to remove the support for pdfplumber.
Since october 2023, we have support for pypdf, which is also
a pure-python lib and doesn't depend on additional python libs, so it's
kind of a replacement for pdfplumber.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.