mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[IMP] *_guess_partner: Also try to check on transaction['name']
This commit is contained in:
@@ -23,16 +23,16 @@ class AccountBankStatementImport(models.TransientModel):
|
|||||||
"""Try to find partner by searching invoice with reference."""
|
"""Try to find partner by searching invoice with reference."""
|
||||||
if transaction.get("partner_id", False):
|
if transaction.get("partner_id", False):
|
||||||
return
|
return
|
||||||
if not transaction.get("ref", False):
|
|
||||||
return
|
|
||||||
ref = transaction["ref"]
|
|
||||||
invoice_model = self.env["account.move"]
|
invoice_model = self.env["account.move"]
|
||||||
# We search each possibility in a separate statement, to prioritize
|
invoice = None
|
||||||
# invoice_origin over ref, and ref over name.
|
transaction_keys = ["ref", "name"]
|
||||||
invoice = invoice_model.search([("invoice_origin", "=", ref)], limit=1)
|
invoice_fields = ["invoice_origin", "ref", "name"]
|
||||||
if not invoice:
|
for key in transaction_keys:
|
||||||
invoice = invoice_model.search([("ref", "=", ref)], limit=1)
|
value = transaction.get(key, False)
|
||||||
if not invoice:
|
if not value:
|
||||||
invoice = invoice_model.search([("name", "=", ref)], limit=1)
|
continue
|
||||||
if invoice:
|
for fieldname in invoice_fields:
|
||||||
transaction["partner_id"] = invoice.partner_id.id
|
invoice = invoice_model.search([(fieldname, "=", value)], limit=1)
|
||||||
|
if invoice:
|
||||||
|
transaction["partner_id"] = invoice.partner_id.id
|
||||||
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user