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

[REF] account: create 'account.reconciliation.widget' model #22274

Merged
merged 4 commits into from
Feb 27, 2018

Conversation

Gorash
Copy link
Contributor

@Gorash Gorash commented Jan 16, 2018

Contains widget reconciliation methods. This refactoring does not modify
the feature, some errors have been notified in the code but not modified.

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

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

@C3POdoo C3POdoo added the RD research & development, internal work label Jan 16, 2018
@Gorash Gorash force-pushed the master-ref-widget-reconciation-chm branch 4 times, most recently from 7331c88 to 6eb63aa Compare January 22, 2018 10:30
Copy link
Contributor

@oco-odoo oco-odoo left a comment

Choose a reason for hiding this comment

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

A few details ;)

Furthermore (and this is much more important), your refactoring will impact account_batch_deposit module (which adds the support for batch deposits to the reconciliation wizard). Could you create an enterprise branch and modify it in accordance with the new version of the reconciliation wizard, please ? :) (For your information, there is some change coming for this module, currently awaiting review ; if it is merged before you're done, account_batch_deposit won't exist anymore, and will be renamed account_batch_payment)

def auto_reconcile(self, st_line_ids, num_already_reconciled_lines=0):
""" :param st_line_ids
:param num_already_reconciled_lines
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no use in listing the parameters like this if you don't explain what they contain ;)

:param str:
:param offset:
:param limit:
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as before, listing the parameters without explanation is pointless.

""" Get statement lines of the specified statements or all unreconciled statement lines and try to automatically reconcile them / find them a partner.
Return ids of statement lines left to reconcile and other data for the reconciliation widget.
"""
bank_statement_ids = self.env['account.bank.statement'].browse(bank_statement_ids)
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency with the rest of your code, I'd rather go for:

bank_statements = self.env['account.bank.statement'].browse(bank_statement_ids)
(and then use bank_statements instead of ban_statement_ids in what follows, of course)

This way, we know that a variable called ..._ids in a list of ids, while ... is directly a recordset.


Account_move_line = self.env['account.move.line']
Account = self.env['account.account']
Currency = self.env['res.currency']
Copy link
Contributor

Choose a reason for hiding this comment

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

Storing these three models in separate variables is pointless here, as we only use them once in the lines that follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In many of the odoo methods, we declare the model variables at the top of the method in order to quickly know what are the links to the other models. I use the same guide lines.

####################################################

@api.model
# _get_move_lines_for_reconciliation
Copy link
Contributor

Choose a reason for hiding this comment

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

little typo: it's get_move_lines_for_reconciliation (without underscore) ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. _ prefix is use for private methods and do not have access from rpc or other. It's private methods only called by this model

Copy link
Contributor Author

@Gorash Gorash Feb 7, 2018

Choose a reason for hiding this comment

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

oups, exact, the comment is wrong, I look the refactoring, sorry

return data

@api.model
# _get_reconciliation_proposition
Copy link
Contributor

Choose a reason for hiding this comment

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

small typo : get_reconciliation_proposition (no underscore)

return Account_move_line

@api.model
# _get_reconciliation_proposition
Copy link
Contributor

Choose a reason for hiding this comment

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

get_reconciliation_proposition (no underscore)


Account_move_line = self.env['account.move.line']

# todo: remove crappy, self is an empty record set
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand what you mean in this TODO; could you make it a little more explicit ? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

old copy past, but I refactored this code and I forget to remove the comment

raise UserError(_('A reconciliation must involve at least 2 move lines.'))

account_move_line = self.env['account.move.line'].browse(move_line_ids)
writeoff_lines = self.env['account.move.line']
Copy link
Contributor

Choose a reason for hiding this comment

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

Why moving this outside the condition ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

idem guide lines

@@ -13,3 +13,4 @@
from . import company
from . import res_config_settings
from . import account_cash_rounding
from . import widget_reconciliation
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming it reconciliation_widget would sound more like actual English ;p

@Gorash
Copy link
Contributor Author

Gorash commented Feb 7, 2018

I forgot to create the pr in enterprise, sorry

@Gorash
Copy link
Contributor Author

Gorash commented Feb 7, 2018

@Gorash
Copy link
Contributor Author

Gorash commented Feb 7, 2018

@oco-odoo ok ? (I'll merge the commit to adapt the pr in the previous commit after)

@oco-odoo
Copy link
Contributor

oco-odoo commented Feb 8, 2018

@Gorash Yup! For me, it's alright :) (also the enteprise branch) Laura will test it, and then we can merge :)

@Gorash Gorash force-pushed the master-ref-widget-reconciation-chm branch 3 times, most recently from c2d76ab to 25b5ed1 Compare February 12, 2018 08:47
Copy link
Contributor

@qdp-odoo qdp-odoo left a comment

Choose a reason for hiding this comment

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

the python refactoring looks good in the overall, I just have few questions.


@api.model
# get_move_lines_for_reconciliation
def _get_move_lines(self, aml_accounts, partner_id, excluded_ids=None, search_str=False, offset=0, limit=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you motivate the removal of the parameters overlook_partner and additional_domain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a modification, to have a method returning the domain. additional_domain and overlook_partner are never used in master or enterprise. If a community module needs to use it, just make an inheritance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

overlook_partner is also use by _get_common_sql_query, I did not change this method, but it was never use in the get_move_lines_for_reconciliation method calls.

<field name="amount">750.0</field>
<field name="date" eval="time.strftime('%Y')+'-01-01'"/>
</record>

Copy link
Contributor

Choose a reason for hiding this comment

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

do you use this demo data somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, in the new tests.
I have add a tour to test different type of reconciliation. There will be more tests coming (according to information provided by Laura)

@MiquelRForgeFlow
Copy link
Contributor

MiquelRForgeFlow commented Feb 23, 2018

Taking advantage of this refactoring, maybe you could also consider adding the companies like in #23070. It could be interesting and useful for people who work in more than one company. 😉

@Gorash
Copy link
Contributor Author

Gorash commented Feb 26, 2018

@mreficent We will see this, but in a second time, so that people have already benefited from refactoring

@Gorash Gorash force-pushed the master-ref-widget-reconciation-chm branch 6 times, most recently from 6bc8772 to e391395 Compare February 26, 2018 15:46
@qdp-odoo
Copy link
Contributor

[IMP] account_batch_deposit: remove comments useful for forward-port

wrong module, Christophe ... can you rework the history when you're done with this branch? thanks

@Gorash
Copy link
Contributor Author

Gorash commented Feb 27, 2018

@qdp-odoo of course, I copied the message from the enterprise branch without paying attention ^^

Gorash and others added 3 commits February 27, 2018 12:06
Contains widget reconciliation methods. This refactoring does not modify
the feature, some errors have been notified in the code but not modified.
… sql

Simplification of the search method of the lines lines (for the
propositions) of the two requests in one. The sql query returns the two
matching lines without filtering after the request because we inject the
rules of access rules directly into it.
This is an optimization in terms of clarity and speed. In addition to the
fix because the previous browse does not use access rules.
@Gorash Gorash force-pushed the master-ref-widget-reconciation-chm branch from e391395 to c7b4d5c Compare February 27, 2018 11:06
@qdp-odoo
Copy link
Contributor

cool. let me know when you're done on this task so that I can close the PR

@Gorash Gorash merged commit 832b472 into odoo:master Feb 27, 2018
@Gorash Gorash deleted the master-ref-widget-reconciation-chm branch February 27, 2018 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants