odoo公​​司可以共享同一个合作伙伴吗?在哪些情况下?

时间:2015-10-05 10:56:37

标签: python python-2.7 odoo-8 odoo erp

我已经看到了创建新公司的odoo代码:

def create(self, cr, uid, vals, context=None):
    if not vals.get('name', False) or vals.get('partner_id', False):
        self.cache_restart(cr)
        return super(res_company, self).create(cr, uid, vals, context=context)
    obj_partner = self.pool.get('res.partner')
    partner_id = obj_partner.create(cr, uid, {'name': vals['name'], 'is_company':True, 'image': vals.get('logo', False)}, context=context)
    vals.update({'partner_id': partner_id})
    self.cache_restart(cr)
    company_id = super(res_company, self).create(cr, uid, vals, context=context)
    obj_partner.write(cr, uid, [partner_id], {'company_id': company_id}, context=context)
    return company_id

前三行似乎允许使用指定的合作伙伴创建新公司..

这似乎故意省略了给定合作伙伴与新创建的公司(最后一次返回之前的行)的关联。

这是一个错误还是他们想让公司与另一家公司分享合作伙伴?在哪种情况下这会有用吗?。

1 个答案:

答案 0 :(得分:4)

As far as I know, in Odoo 8 or older, it's not possible to share a contact between companies. A lot of customers asked me for implementing that, because they wanted to introduce contacts who work in several companies (and even those contacts were the main contact of those companies).

In fact, you can check the behaviour of the official module base_contact to share contacts between companies. If you read the code of this module, you will realize that actually they are creating several contacts for each company, and then they hide them in order to make the user see only one of them.

Example: you create a contact named Yucer in the company Odoo (this contact will be created as standalone type). Then, you want to indicate that this partner also works for the company StackExchange. When you do this, another contact (with the same data of Yucer) is stored in the database, with the type attached. When you search for Yucer, you will only see the standalone one, but if you check Odoo and StackExchange, you will see Yucer in both of them. They also modified ORM methods of res.partner model like unlink, to remove all cloned contacts when you remove the main one.

相关问题