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
[FIX] hr_expense: bill partner child contact #159911
base: 16.0
Are you sure you want to change the base?
Conversation
Hello @Levizar |
@JulienAlardot Could you have a look at it? OFC, @agr-odoo is right, it doesn't make sense to reimburse the company instead of the employee. |
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.
100% a bug, but this fix confuses me a lot 🤔
if self.payment_mode == 'company_account': | ||
partner_id = self.employee_id.sudo().address_home_id.commercial_partner_id.id |
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 should never be the case, as only own_account expenses call this one
if self.payment_mode == 'company_account': | ||
partner_id = self.employee_id.sudo().address_home_id.commercial_partner_id.id | ||
else: | ||
partner_id = self.employee_id.id |
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.
self.env['res.partner'] != self.env['hr.employee']
if self.payment_mode == 'company_account': | ||
partner_id = self.employee_id.sudo().address_home_id.commercial_partner_id.id | ||
else: | ||
partner_id = self.employee_id.id |
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.
Did you test the fix because I'm surprised it works.
We discussed it a bit with JUAL and unless I'm mistaken, self.employee_id
isn't a res.partner
and thus it is probably working by chance. :/
My bad, it seems I left this 'fix' in an inconsistent state and forgot about it 😅 |
Open a [DEMO] employee record Set the Bank Account Number under 'Private Information' Open the contact (res.partner) of [DEMO] Set the parent contact to be the current company Add a bank account on the contact for current company Go to Expenses and create a new expense for [DEMO], with Paid By "Employee (to reimburse)" Create Report, Submit Report, Approve, then Post Journal Entries. Issue: On the created bill, partner will be the parent company and also the bank account will be the one of the parent company. When registering payment from: - bill: the user will see the bank account of the company - expense: the user will see the bank account of the employee opw-3800134
463d735
to
6cbe354
Compare
First of all I apologize If I pinged you on a very much draft PR By default the move partner is the commercial partner, so in this use case, it would be the parent company, from which the system computes the appropriate bank account Then, if we look at the register payment wizardon the expense form, we find this override to select the employee account
In conclusion, this might be an expected limitation so the user should either:
|
@agr-odoo Couldn´t we set a context key before retrieving the account to use and in the method that finaly retrieves it, check for the context key to early return the partnerś bank account and avoid using the company one? |
Open a [DEMO] employee record
Set the Bank Account Number under 'Private Information'
Open the contact (res.partner) of [DEMO]
Set the parent contact to be the current company
Add a bank account on the contact for current company
Go to Expenses and create a new expense for [DEMO], with Paid By "Employee (to reimburse)"
Create Report, Submit Report, Approve, then Post Journal Entries.
Issue: On the created bill, partner will be the parent company and also
the bank account will be the one of the parent company.
When registering payment from:
opw-3800134