Skip to content

Commit

Permalink
8.0 Add support for partner bank matching on invoice update (#6)
Browse files Browse the repository at this point in the history
Add support for partner bank matching on invoice update (before, it was only supported on invoice creation)
  • Loading branch information
Alexis de Lattre authored and gbrito committed Mar 28, 2023
1 parent 642d924 commit 872476f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base_business_document_import/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ Usage

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/95/8.0
:target: https://runbot.odoo-community.org/runbot/226/8.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/account-invoicing/issues>`_. In case of trouble, please
<https://github.com/OCA/edi/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.

Expand Down
30 changes: 30 additions & 0 deletions base_business_document_import/models/business_document_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,36 @@ def _match_shipping_partner(self, shipping_dict, partner, chatter_msg):
partner = partners[0]
return partner

@api.model
def _match_partner_bank(
self, partner, iban, bic, chatter_msg, create_if_not_found=False):
assert iban, 'iban is a required arg'
assert partner, 'partner is a required arg'
partner = partner.commercial_partner_id
iban = iban.replace(' ', '')
rpbo = self.env['res.partner.bank']
self._cr.execute(
"""SELECT id FROM res_partner_bank
WHERE replace(acc_number, ' ', '')=%s
AND state='iban'
AND partner_id=%s
""", (iban, partner.id))
rpb_res = self._cr.fetchall()
if rpb_res:
return rpbo.browse(rpb_res[0][0])
elif create_if_not_found and bic:
partner_bank = rpbo.create({
'partner_id': partner.id,
'state': 'iban',
'acc_number': iban,
'bank_bic': bic,
})
chatter_msg.append(_(
"The bank account <b>IBAN %s</b> has been automatically "
"added on the supplier <b>%s</b>") % (
iban, partner.name))
return partner_bank

@api.model
def _match_product(self, product_dict, chatter_msg, seller=False):
"""Example:
Expand Down

0 comments on commit 872476f

Please sign in to comment.