跳至內容
選單
此問題已被標幟
1 回覆
6604 瀏覽次數

Hello, 


I want to solve this error 


Something went wrong !

×

Incompatible companies on records: - 'com/MO/05031 - product ref. - product name' belongs to company 'company name' and 'Leave' (leave_id: 'com/MO/05031 - routing name) belongs to another company.


waiting anyones help,

Thanks in advance,


頭像
捨棄

Hi!! Same error while creating a new company!! Any news?

Hello Iman,

Kindly, check the product configuration.
Like selected product allow for a single company or multiple company?

最佳答案

Hello,

I faced this issue in Odoo 15, and I was investigating for the cause of it, I suspected that it was a customization made which caused it so took a backup and I began to uninstall all custom modules but the error still pop up. I created a new database installing the native modules I am using but the error did not pop up which is very strange, on debugging the code I found that on creating a new company the partner_id is created with a company_id equal 1 not the id of the company which is being created, honestly I do not know why? as the regular behavior to be equal False or equal to the id of the company being created.

 Finally I fixed this issue by overriding the create method of the res.company:

class Company(models.Model):
_inherit = "res.company"

@api.model
def create(self, vals):
company = super(Company, self).create(vals)
# Add the following line to avoid user error: Incompatible companies on records.
company.partner_id.company_id = company.id # or you can make it = False
return company

I hope it helps someone. 

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
6月 21
2189
3
11月 23
6793
1
1月 23
1426
4
1月 22
4915
0
2月 20
58