Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
11307 Lượt xem

In the sale.order model, the create() method contains this if-statement:

if 'company_id' in vals:
    vals['name'] = self.env['ir.sequence'].with_context(force_company=vals['company_id']).next_by_code('sale.order') or _('New')
else:
    vals['name'] = self.env['ir.sequence'].next_by_code('sale.order') or _('New')
I've figured out the sequences, but I am very confused as to what  with_context(force_company=vals['company_id']) does. 

Can you use it to define independent sequences within the same data.xml using different contexts? (In this case, using the vals['company_id'] value.) If so, what exactly is force_company? How can I add a custom context, without force_company?

Thanks in advance for your help!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

hello

force_company means if the multi company feature is enable into the system at that time if the multiple sequence of sale's order exist so get the sequence of sale order based on the current company selected on the sales order.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 15
3525
0
thg 3 18
4808
2
thg 4 24
4032
1
thg 11 15
5732
0
thg 3 15
5775