Help

3

Auto-expand the Chart of Accounts? Possible?

Avatar
Ray Carnes

The Chart of Accounts by default is shown collapsed:

image description

I'd like it shown fully expanded by default, instead of requiring the user to click on all of the expand arrows:

image description

Avatar
Discard
4 Answers
3
Avatar
Ray Carnes
Best Answer

UPDATED 5/26/15 (I added a git compatible patch for v8)

ORIGINAL ANSWER:

----------------------------------------------------------------------------------------------------------------

This is possible by adding several lines to the view_tree.js file in web addons.

Use the following bzr patch files:

v7

=== modified file 'addons/web/static/src/js/view_tree.js'
--- addons/web/static/src/js/view_tree.js 2013-08-29 12:44:48 +0000
+++ addons/web/static/src/js/view_tree.js 2014-03-23 20:10:31 +0000
@@ -210,6 +210,11 @@
} else {
self.$el.find('tbody').html(children_rows);
}
+ _(records).each(function (record) {
+ self.records[record.id] = record;
+ children_ids = record[self.children_field];
+ self.getdata(record.id, children_ids);
+ });
});
},

v8

=== modified file 'addons/web/static/src/js/view_tree.js'
--- addons/web/static/src/js/view_tree.js 2013-09-10 12:52:23 +0000
+++ addons/web/static/src/js/view_tree.js 2014-03-23 20:13:24 +0000
@@ -213,6 +213,11 @@
} else {
self.$el.find('tbody').html(children_rows);
}
+ _(records).each(function (record) {
+ self.records[record.id] = record;
+ children_ids = record[self.children_field];
+ self.getdata(record.id, children_ids);
+ });
});
},

----------------------------------------------------------------------------------------------------------------

UPDATE:

Use the following git patch file for v8:

index 380f160..0d8a05d 100644
--- a/addons/web/static/src/js/view_tree.js
+++ b/addons/web/static/src/js/view_tree.js
@@ -213,6 +213,11 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
} else {
self.$el.find('tbody').html(children_rows);
}
+ _(records).each(function (record) {
+ self.records[record.id] = record;
+ children_ids = record[self.children_field];
+ self.getdata(record.id, children_ids);
+ });
});
},

3 Comments
Avatar
Discard

Great post Ray!

Avatar
Temur
-

As I guess it'll affect any tree to be opened expanded, not only "Chart of Accounts" ? If so, then your question title does not exactly define what is this change for... please read my !Answer

Avatar
Ray Carnes
-

I am now aware of any other views that are affected by this change, but this is a global change to the way certain types of views are shown.

1
Avatar
NextERP Romania SRL
Best Answer

There was for v7 a module named web_group_expand, but i don't know if it's ported to v8..you can look after it.

1 Comment
Avatar
Discard
Avatar
Temur
-

I've found that module in v7. it's not exactly what I'm looking for, but it may be useful and I'll check if so. thank you very much.

0

Guys,

We've added groupby expand feature on Odoo Apps Web Groupby Expand.

Hope this helps.

Thanks.

1 Comment
Avatar
Discard

It is not working in Odoo v11.

-1
Avatar
Temur
Best Answer

Hi Ray, 

As I guess code you posted in your answer will affect any tree like structure to be opened expanded, not only "Chart of Accounts" ? If so, then your question title does not exactly define what is this change for. However It should be interesting how to do same thing really for "Chart of Accounts", not for any tree (I do not want to affect other trees). Additionally I've requirement to expand Chart of Accounts to some level (lets say 1 or 2), not Fully as it's in your case. If I expand to level 1, so on second picture in the question above, account "1" will be displayed expanded and accounts "100" and "150" collapsed. If I decide to expand to level 2, then picture in this example will be same, but if the tree has more deep, so next levels will be collapsed. i.e. if in this picture account "1399" will be of "view" type and have children, then it'll displayed collapsed and so on.  Any tips?

Regards,

Avatar
Discard