Skip to content

Commit

Permalink
account_invoice_import: improve handling of simple PDF invoices
Browse files Browse the repository at this point in the history
Implement what is described in issue OCA#610:
- account_invoice_import_simple_pdf and account_invoice_import_invoice2data can now be use
d together
- when importing an invoice for an unknown partner, it creates an empty invoice with PDF a
s attachment
- when importing an invoice via mail gateway and the from email is set
on a partner that doesn't have any import config, create a supplier
invoice with PDF as attachment and with that partner
- when importing an invoice via mail gateway and the from email is set
on a partner that has a single-line import config, create a supplier
invoice with PDF as attachment, that partner and 1 invoice line with price_unit=0.
  • Loading branch information
alexis-via authored and kevinxdev committed Dec 26, 2022
1 parent 0e02468 commit d1ee18f
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def fallback_parse_pdf_invoice(self, file_data):
"""This method must be inherited by additional modules with
the same kind of logic as the account_bank_statement_import_*
modules"""
return self.simple_pdf_parse_invoice(file_data)
res = super().fallback_parse_pdf_invoice(file_data)
if not res:
res = self.simple_pdf_parse_invoice(file_data)
return res

@api.model
def _simple_pdf_text_extraction_pymupdf(self, fileobj, test_info):
Expand Down Expand Up @@ -327,7 +330,8 @@ def simple_pdf_parse_invoice(self, file_data, test_info=None):
raw_text_dict = self.simple_pdf_text_extraction(file_data, test_info)
partner_id = self.simple_pdf_match_partner(raw_text_dict["all_no_space"])
if not partner_id:
raise UserError(_("Simple PDF import: could not find vendor."))
parsed_inv = {"chatter_msg": ["Simple PDF Import: count not find Vendor."]}
return parsed_inv
partner = rpo.browse(partner_id)
raw_text = (
partner.simple_pdf_pages == "first"
Expand Down

0 comments on commit d1ee18f

Please sign in to comment.