Odoo Help

Welcome!

This community 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.

0

Consolidation chart of account wizard

By
Koffi KPONOUGLO
on 9/2/16, 6:09 AM 167 views

Hi,

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,

context=context)

subsidiary_account_id = account_obj.search(cr, uid,

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

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

context=context)

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],

context=browse_ctx)

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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