Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3560 มุมมอง

I did some code to update the child partner records automatically upon modification of a field, stock_owner_id. I overwrote the "write" function to achieve that.

 @api.multi
    def write(self, vals):
        """ This will overwrite children stock owner to the same as the current one.
        """
        soid = vals.get('stock_owner_id')
        
        if soid is not None:
            children = self.search([('parent_id', 'child_of', self.ids)])
            
            if children:
                children.write({'stock_owner_id': soid})
                
        result = super(Partner, self).write(vals)
        
        return result
The problem is that the "write" function is triggered for each child write and that trigger other useless queries on the database.

Any suggestion to prevent that behaviour and still update all my children in bulk?

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
How to become a Odoo Ready Partner ? แก้ไขแล้ว
1
พ.ค. 23
5800
2
มี.ค. 19
11480
2
พ.ย. 17
12146
1
มี.ค. 15
7482
1
มี.ค. 15
5335