hi,
where can i found this field, company_ids, is an array, in table res_users not exist.
thx
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
hi,
where can i found this field, company_ids, is an array, in table res_users not exist.
thx
Hello Zouhair, the field is not present on res_users table but it's contained in 'res_company_users_rel'
CREATE TABLE res_company_users_rel
(
cid integer NOT NULL,
user_id integer NOT NULL,
CONSTRAINT res_company_users_rel_cid_fkey FOREIGN KEY (cid)
REFERENCES res_company (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE,
CONSTRAINT res_company_users_rel_user_id_fkey FOREIGN KEY (user_id)
REFERENCES res_users (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE,
CONSTRAINT res_company_users_rel_cid_user_id_key UNIQUE (cid , user_id )
)
In addons/base/res/res_users.py (OpenERP v7)
_columns = {
....
'company_ids':fields.many2many('res.company','res_company_users_rel','user_id','cid','Companies'),
...
}
In Base Module base/res/res_users.py file company_ids added.
company_ids is many2many field in DB it create res_company_users_rel table.
The message shows from the write method base/res/res_partner.py File.
At the time of creating or updating user check the below conditon
# res.partner must only allow to set the company_id of a partner if it
# is the same as the company of all users that inherit from this partner
# (this is to allow the code from res_users to write to the partner!) or
# if setting the company_id to False (this is compatible with any user
# company)
@api.multi
def write(self, vals):
if vals.get('website'):
vals['website'] = self._clean_website(vals['website'])
if vals.get('company_id'):
company = self.env['res.company'].browse(vals['company_id'])
for partner in self:
if partner.user_ids:
companies = set(user.company_id for user in partner.user_ids)
if len(companies) > 1 or company not in companies:
raise osv.except_osv(_("Warning"),_("You can not change the company as the partner/user has multiple user linked with different companies."))
result = super(res_partner, self).write(vals)
for partner in self:
self._fields_sync(partner, vals)
return result
hello,
thank you Prakash ,Daniele Lanfranchi for ur help, i want to create a new user into new company by odoo api, but i can do it, i give this msg error
You can not change the company as the partner/user has multiple user linked with different companies.
any one can help me
thx in advance
I updated my answer
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
creation of company
Đã xử lý
|
|
1
thg 10 24
|
12594 | |
|
0
thg 10 22
|
2339 | ||
|
1
thg 4 15
|
4581 | ||
|
0
thg 3 15
|
4393 | ||
|
1
thg 3 15
|
4492 |