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

Hello, 

Can you explain me this Python function ? 

    @api.model
    def create(self, vals):
        record = super(ResPartnerSchool, self).create(vals)
        record.no_duplicate_school_dates()
        if not self.env.context.get('tracking_disable'):
            record.changed_half_pension()
        return record

and specially :

        if not self.env.context.get('tracking_disable'):
            record.changed_half_pension()

Thanks you

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

if not self.env.context.get('tracking_disable') this means if context does not have
"tracking_disable" or {'tracking_disable': False}

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

hello,

if not self.env.context.get('tracking_disable'):   
record.changed_half_pension()
this context you will get at the time when you import the csv file into odoo. so whenver you  
upload the csv file data to the system at that time the create method is call. so when you didn't
get the context at that time record.changed_half_pension() method will call. and when you import the
data from import button at that time record.changed_half_pension() this method will not call.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 25
2506
3
thg 2 25
3807
0
thg 5 24
46
1
thg 4 24
3514
4
thg 9 23
5058