-
-
Notifications
You must be signed in to change notification settings - Fork 310
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
8.0 Add support for partner bank matching on invoice update #6
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why make this with SQL? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need the replace() method in SQL because the IBAN can have spaces in res_partner_bank. In v9, this problem is solved by the acc_number_sanitized field, so I will remove this SQL request in v9 and use the ORM instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
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(_( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have to modify the translations due to this file change I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Translations are handled automatically via transifex, no ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but you will lose any of the already present translations. It's just to check and modify translation files to see the comment line about the code that contains this sentence. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no translation for this module so far. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
"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: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it more tolerant, put
chatter_msg
as optional.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm, it is that way in all the other methods of this module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you can start with this one being more tolerant 😉 for reusing it in models without chatter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I'll change that, I'll change it everywhere ; I don't want to do it partially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good moment for that 😉, but I know that you're not going to do it, hehe