Monday, October 01, 2012

Company_id default value

Looking at base objects in OpenERP is always source of inspiration.

I found the following

 'company_id': lambda s,cr,uid,c: s.pool.get('')._company_default_get(cr, uid, 'res.partner', context=c),

So there is a method for finding the company_id to use for an object - here a partner. Company_id is important since this field is used for partitioning your db between different companies.

Even better looking at res.partner, I found  ab oject called  'multi_company.default' !

Basically there is a small  and 'hidden' rules engine to set company_id ! Nice. 

No comments: