Skip to content
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] account move line default_get #25298

Closed
wants to merge 4 commits into from
Closed

[FIX] account move line default_get #25298

wants to merge 4 commits into from

Conversation

PieterPaulussen
Copy link
Contributor

Description of the issue/feature this PR addresses:
The default get does not support multiple account_move_line's calculated debit/credit.

Current behavior before PR:
The move line's debit and credit are calculated from a hardcoded counterpart. (line[2]).

Desired behavior after PR is merged:
Return a calculated debit/credit from all move lines related to the move.

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@pedrobaeza
Copy link
Collaborator

I don't get what is the problem, but you shouldn't change so much code if you want this to be clear for having it merged. You need to sign the CLA also.

@PieterPaulussen
Copy link
Contributor Author

@pedrobaeza The diff is 10 lines. Are you seeing something else than me?
I added the CLA thanks.

@pedrobaeza
Copy link
Collaborator

10 lines which doesn't differ in fact, because you want to add a new cyclomatic complexity level with no benefit, so please remove that extra if.

@PieterPaulussen
Copy link
Contributor Author

@pedrobaeza Thanks for the tip! I simplified the PR.

@pedrobaeza
Copy link
Collaborator

Is this applicable also to other branches?

@qdp-odoo can you review this one?

@PieterPaulussen
Copy link
Contributor Author

@pedrobaeza Well, V9.0 and V10.0 both didn't include a default get for account_move_line. So either it was solved in a different way, or it's isn't included at all. V8.0 has a completely different implementation (Which by the way is very slow. in computation.).

@pedrobaeza
Copy link
Collaborator

OK, thanks for the insight. Take into account that master is an alpha version, so some problems are expected to happen. Any way, it's good to have this fixed.

for line in self._context['line_ids']:
if line[2]:
balance += line[2].get('debit', 0) - line[2].get('credit', 0)
for line in self.env['account.move'].resolve_2many_commands('line_ids', self._context['line_ids']):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolve_2many_commands is defined on the model level, not specifically on account.move so you can use self.resolve_2many_commands

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can pass an extra parameter with the fields you need. fields=['debit', 'credit']

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StefanRijnhart I think you mean self.move_id.resolve_2many_commands(...). I will update with your comments, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, you are right. It's the line_ids field of account.move of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StefanRijnhart I updated the PR and fixed the CLA to the corporate version in a separate commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR is looking good! I think legal wise, Stijn Houben needs to commit the addition to the corporate CLS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I discussed it internally with the Dynapps developers and they agreed I should do this: #25336. ;-)

@qdp-odoo
Copy link
Contributor

nice catch.

Landed in master, at revision 50ee1c9

Thank you all for the bug report, the fix and the reviews :-)

@qdp-odoo qdp-odoo closed this Jun 20, 2018
qdp-odoo pushed a commit that referenced this pull request Jun 20, 2018
When creating a journal entry manually, the value proposed as next line was not taken into consideration all existing lines.

Was PR #25298. Courtesy of Pieter Paulussen (Dynapps)
len-foss pushed a commit to odoo-dev/odoo that referenced this pull request Aug 19, 2019
Backport of 50ee1c9.
Previous version was buggy, as it was already patched by 54c2c08 and 862c245.

When creating a journal entry manually, the computed value for the next line
was not taking into consideration all existing lines.
Was PR odoo#25298. Courtesy of Pieter Paulussen (Dynapps)
robodoo pushed a commit that referenced this pull request Aug 21, 2019
Backport of 50ee1c9.
Previous version was buggy, as it was already patched by 54c2c08 and 862c245.

When creating a journal entry manually, the computed value for the next line
was not taking into consideration all existing lines.
Was PR #25298. Courtesy of Pieter Paulussen (Dynapps)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants