Trunk Multi Company Improvement
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Specifications to Improve Multi-Company in Trunk
=======
These specs details security issues for the multi-company only. Others issues (sales -> purchase, outgoing -> incoming) are detailed in others specifications. The security for the multi-company is based on the following concept:
- multi-company objects have a field called 'company_id': fields.
-> sometimes required, sometimes not. Sometimes with a default value.
- records are based on record rules that filter objects based on this field.
Modifications in the client and the server so that a user belongs to several companies have already been applied.
Merge Modules
-------------------
We do not need multi-company modules anymore. Every module most be multi-company by default.
In trunk, we must merge multi_company_XXX modules in their respective modules, put directly the
company_id field on the object, no inheritancy of object/view anymore.
Each time you put a company_id field on an object, do:
* A default value (see bellow for more info):
'company_id': lambda self,cr,uid,c: self.pool.
I don't know if _name will work. Otherwise put the name of the object 'account.invoice'
* Some multi_company fields must be related fields. For example, in sale.order.line:
'company_id': fields.
Do the same for:
- purchase.order.line
- account.
- task.work.line
* A record rule like this one for this object:
<record id="journal_
<field name="name">Journal multi-company (Children+
<field model="ir.model" ref="model_
<field eval="True" name="global"/>
</record>
<record id="journal_
<field model="
<field name="domain_
<field name="rule_group" ref="journal_
</record>
This rule must be put on all generic objects (partners, products, ...)
For more sensible objects (like all accounting and sales objects), use a rule like this one:
<record id="journal_
<field name="name">Journal multi-company (Children)</field>
<field model="ir.model" ref="model_
<field eval="True" name="global"/>
</record>
<record id="journal_
<field model="
<field name="domain_
<field name="rule_group" ref="journal_
</record>
-> The way record rules were defined in old multi-company modules was wrong, change all rules to be like the above one.
On the view, add a group on all company_id field, so that users belonging to a single company have a way to hide
all multi-company fields:
<field name="company_id" groups=
The multi_company module
-------
Develop a multi_company module (or improve the existing one). It has no code nor security rules at all.
It just define demonstration data with a several companies and assign some companies to some products, partners, ...
The default value system
-------
Put this in the base module, on res.company object:
+ def _company_
+ return self.pool.
Put this in multi_company module:
+class multi_company_
+ _name = 'multi_
+ _order = 'sequence,id'
+ _columns = {
+ 'sequence': fields.
+ 'name': fields.char('Name', size=32, required=True),
+ 'company_id': fields.
+ 'company_dest_id': fields.
+ 'object_id': fields.
+ 'expression': fields.
+ }
+ _defaults = {
+ 'expression': lambda *a: 'True',
+ 'sequence': lambda *a: 1
+ }
+multi_
+
+class res_company(
+ _inherit = 'res.company'
+ def _company_
+ proxy = self.pool.
+ ids = proxy.search(cr, uid, [('object_id.name', '=', object)]
+ for rule in proxy.browse(cr, uid, ids, context):
+ user = self.pool.
+ if eval(rule.
+ return rule.company_
+ return super(res_company, self)._
+res_company()
Define a menu and a view to configure the multi_company.
Put a security rule a multi_company security rule on this object too.
Changed in openobject-addons: | |
status: | Confirmed → In Progress |
Changed in openobject-addons: | |
status: | In Progress → Fix Committed |
vra, can you let me know when this task is merged in to the trunk branch.
Thanks,