[REF][8.0][hr_payroll_account] Get partner_id with a function to inheritable case#3385
[REF][8.0][hr_payroll_account] Get partner_id with a function to inheritable case#3385
Conversation
|
Hello, Are you trying to fix a bug ? Can you give a way to reproduce ? |
|
@mart-e, |
…t-get-partner-dev-moylop260
|
@mart-e |
|
Hello, I agree it could be useful to compute the salary based on the partner. However this would be for master as not a bug fix (but you can keep this PR I will rebase while merging). Thanks to new API you don't need to do things like If I understand correctly the 5 lines condition to assign |
|
Hello @mart-e I see many refactory case in this code, but I'm using the current original code for no change nothing in this PR. IMHO changes of logic or new api should be in other PR. |
|
I don't mean to refactor the whole computation (as you say keep the diff minimum) but in the parts you do rewrite, you can reduce the code to improve the readability. Anyway the part that worries me is the fallback on credit if no debit. Instead of adding a field, wouldn't it be better to extract it in a method with a parameter credit/debit ? |
|
@mart-e Now, What do you think? |
|
Ok to keep the existing code but it has not the same behaviour than the existing code. Let's say your The difference is that we evaluated different conditions in case of debit or credit account, while with your patch, it's one global evaluation. Well I admit it's quite specific but that was the reason I suggested a separated method instead of a computed field. |
|
@mart-e, Then if I add a field function to partner_debit_id and other one to patner_credit_id |
|
Do you feel fine if I add test with this cases: table of cases of test? |
|
I don't get why do you absolutely need to have fields and could not call a method It's usually a good idea to add tests (thanks for the suggestion) but I am not sure it will be very useful for this refactroring. So you can but no need to do the full table. |
There was a problem hiding this comment.
@mart-e
Im confused, sorry.
Can you help me to write your comment into line code as this one, please?
What is the section that I need change it?
I want to help but I don't understand your point.
There was a problem hiding this comment.
Replace this by something like
if credit_account:
res[payslip_line.id] = (payslip_line.salary_rule_id.register_id.partner_id or ayslip_line.salary_rule_id.account_credit.type in ('receivable', 'payable')) and partner_id or False
else:
res[payslip_line.id] = (payslip_line.salary_rule_id.register_id.partner_id or ayslip_line.salary_rule_id.account_debit.type in ('receivable', 'payable')) and partner_id or False
|
@mart-e We will work with this changes. |
…et-partner-dev-moylop260
…l, improvement _get_partner_id function
|
Hello @mart-e I did make the requested changes, you can check the PR again. Thank you! |
There was a problem hiding this comment.
if you are supporting only one id, don't make your argument a list, use a single id as parameter and return the partner_id
|
Thanks for the update. |
|
Thanks, merged the CLA update. |
|
@mart-e, |
…et-partner-dev-moylop260
44d76af to
0595c52
Compare
…_partner_id function, from a list to id
|
@mart-e |
Add method to get partner from hr_payslip_line instead of forcing the current rule Fixes #3385
|
Actually the patch was arleady ready at 075d80afb94a2819e29e1cbb1c815593e65b4268 but I was just waiting for the master branch to be back online. |
Proposal to add a REF - More info here: #3274
OPW ticket 616565