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

[10.0] Restore account hierarchy and views #505

Closed
wants to merge 14 commits into from
Closed

[10.0] Restore account hierarchy and views #505

wants to merge 14 commits into from

Conversation

hongquangminh
Copy link
Member

@hongquangminh hongquangminh commented Jun 17, 2017

Restore account hierarchy and views

@oca-clabot
Copy link

Hey @minhhq09, thank you for your Pull Request.

It looks like some users haven't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here: http://odoo-community.org/page/website.cla
Here is a list of the users:

  • @minhhq09 (login unknown in OCA database)

Appreciation of efforts,
OCA CLAbot

Configuration
=============

Need to set the group show chart of account structure to view the chart of account heirarchy.
Copy link
Contributor

Choose a reason for hiding this comment

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

heirarchy should be hierarchy

<field name="implied_ids" eval="[(4, ref('account.group_account_manager'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
</odoo>
Copy link
Contributor

Choose a reason for hiding this comment

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

You should change the logo of the module.

Maybe this one: https://upload.wikimedia.org/wikipedia/commons/9/9c/Categorisation-hierarchy-top2down.svg

@hongquangminh hongquangminh changed the title first create account_parent Restore account hierarchy and views Jun 19, 2017
@oca-clabot
Copy link

Hey @minhhq09,
We acknowledge that the following users have signed our Contributor License Agreement:

  • @minhhq09

Appreciation of efforts,
OCA CLAbot


@api.model
def _move_domain_get(self):
context = dict(self._context or {})
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this function should return 2 values:

  • domain
  • params

Then you can build safely the SQL query avoiding SQL injection.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for your comment :)

I did rewrite the query to avoiding SQL injection in compute function.
The function compute for each account. So we just need get domain in here

Copy link
Contributor

Choose a reason for hiding this comment

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

{'show_parent_account': True}).search([
('id', 'child_of', [account.id])])
params = [tuple(sub_accounts.ids)]
self.env.cr.execute(query, params)
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that we could execute the query only once and outside the for loop using a group by l.account_id in the query. This should help with performance.

Copy link
Member Author

Choose a reason for hiding this comment

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

Like i say above. Compute value just for each account. In Vietnamese, the parent account can sum debit/credit value of childrent account. Example: I want report debit, credit, balance off account: 111 - Cash. The function will return sum debit, credit of childrent account is: 1111, 1112, 1113

Copy link
Contributor

Choose a reason for hiding this comment

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

When you open the Chart of Account Hierarchy, you display several accounts and for each balance, sum debit and sum credit at the same time.

You should execute the SQL query only once for all accounts.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's funtion fields will be automated compute value. I think it don't the same when you click on button and compute value of all account.

The wizard no call to that function. It just show hierarchy view with already exist data. When you find any account you also can see debit, credit, balance.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am 99% sure that if you add self.ensure_one() as the first line of def _compute_values you won't be able to open the hierarchical view of accounts.

I think that the function _compute_values will be called with self that will be a recordset of multiple accounts.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, i will try fix it one more time.

Thank JC,

'company_id': self.company_id
})

# Test that the open chart cannot open window
Copy link
Contributor

Choose a reason for hiding this comment

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

From:

        # Test that the open chart cannot open window

To

        # Test that the function account_chart_open_window can be executed
        # without arguments/special context

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay :)

==============

This module will be very useful for those who are still using v7/v8
because of the no parent account and chart of account heirarchy view in the latest versions
Copy link
Contributor

Choose a reason for hiding this comment

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

5 iterations of heirarchy instead of hierarchy in the code of this PR


@api.model
def _move_domain_get(self):
context = dict(self._context or {})
Copy link
Contributor

Choose a reason for hiding this comment

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

@hongquangminh hongquangminh changed the title Restore account hierarchy and views [10.0] Restore account hierarchy and views Jun 20, 2017
parent_id = fields.Many2one(
'account.account', 'Parent Account', ondelete='restrict')
child_ids = fields.One2many(
'account.account', 'parent_id', 'Child Accounts')
Copy link

Choose a reason for hiding this comment

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

Hi everyone,

Why don't we just implement the Hierarchy implemented in Odoo/master
that just landed a few days ago at commit odoo/odoo@5967600

This new approach, I think could fit to everyone allowing to provide Hierarchy,
Using the current way can lead to huge overheads to compute the recursive
values of the parent-children accounts, I am aware that we need the Hierarchy
but this new approach leaves the computation of the parent-child values to
reporting and the parent-children relationship is separated into two, that hierarchy
is only left to parents which bear no moves (account.group) and the account.account
is the ultimate children that bears only moves.

As @fpodoo explained at odoo/odoo#17367 (comment)

This is more elegant and less power/resource consuming.

This computed fields will lead to the overhead that once crippled the previous odoo versions.

Best Regards

Copy link

Choose a reason for hiding this comment

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

+1

Copy link

Choose a reason for hiding this comment

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

+1

@api.model
def search(self, args, offset=0, limit=None, order=None, count=False):
context = self._context or {}
if not context.get('show_parent_account', False):
Copy link
Member

Choose a reason for hiding this comment

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

I think it's make better if we check show_parent_account is True. May be, we will change many code.
Because another line in all module don't has set this context before. If we check fail, all line will go into condition
if not context.get('show_parent_account', False): > if context.get('show_parent_account'):

@gurneyalex gurneyalex added this to the 10.0 milestone Oct 16, 2017
@jcdrubay
Copy link
Contributor

So with version 11 it seems that:

  • Odoo has not been using the concept of account.group anywhere in the code (neither community nor enterprise)
  • Odoo has removed the hierarchical view (tree view with a field_parent as we used here) from community.

I wonder what is the best way to have a hierarchy of accounts with balance in version 11 ... :/

@pedrobaeza
Copy link
Member

@jcdrubay, @rlizana has been working in the Madrid code sprint in a tree view using account.group. There's a problem with that view with new JS architecture that should be reported, but the rest is almost done.

@feketemihai
Copy link
Member

feketemihai commented Feb 14, 2018

@pedrobaeza @rlizana Can you put a link from that work, i'm interested too.

@jholze
Copy link

jholze commented Feb 28, 2018

Guys, is there something done already for this topic. We are also searching for an addon to get this backed hierarchy back into odoo.

@jcdrubay
Copy link
Contributor

@pedrobaeza @rlizana @congdpt any news would be welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet