Odoo Help


Consolidation chart of account wizard

on 9/2/16, 6:09 AM 742 views


i would like to consolidate two chart of account (A and B). That mean Chart of account A would be an virtual chart.

I am planning to write an wizar who will help me to set consolidation automaticaly; not manually. The fonction of this wizad will :

-select every account of chart A and set their internal type to "consolidation"

-search accounts who have the same code in the two charts (A and B)

-and then add the account of chart B into child_consol_ids.

So i write this code. 

def consolidate_account(self, cr, uid, ids, holding_account_id, subsidiary_id, context=None):


Consolidates the subsidiary account on the holding account

Creates move lines on the move with id "move_id"

:param holding_account_id: ID of the account to consolidate

(on the holding), the method will

find the subsidiary's corresponding account

:param subsidiary_id: ID of the subsidiary to consolidate

:return: list of IDs of the created move lines


if context is None:

context = {}

account_obj = self.pool.get('account.account')

holding_account = account_obj.browse(cr, uid, holding_account_id,


subsidiary_account_id = account_obj.search(cr, uid,

[('code', '=', holding_account.code),

('company_id', '=', subsidiary_id)],


if not subsidiary_account_id:

# an account may exist on the holding and not in the subsidiaries,

# nothing to do

return []

browse_ctx = dict(context)

# 1st item because the account's code is unique per company

subs_account = account_obj.browse(cr, uid, subsidiary_account_id[0],


for account in subs_account:

holding_account.write(cr, uid, {'type' :'consolidation'}, context = context)

holding_account.append(cr,uid,{'child_consol_ids':account.id}, context=context)

return {'type': 'ir.actions.act_window_close'}

Can you help me.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 9/2/16, 6:09 AM
Seen: 742 times
Last updated: 9/2/16, 6:09 AM