Skip to Content
Menu
This question has been flagged
2 Replies
1999 Views

hello guys, i want to ask you, i have requirements to archived the reordering rules in product template when the product template is archived and activate it when the product template is active.. i've tried to override the toggle_active method.. the process to archived is right but i can't reactivate it again..  here is my code.. can you help me? thank you


i've tried to see the log i didn't get anything when i print archived_order variable: stock.warehouse.orderpoint() ????????????????????????????????????????

    @api.multi
    def toggle_active(self):
        for rec in self:
            if rec.active:
                rec.product_variant_ids.orderpoint_ids.active = False
            else:
                archived_order = self.env['stock.warehouse.orderpoint'].search([('product_id''=', rec.product_variant_ids.id), ('active''='False)], limit=1)
                print(archived_order, "????????????????????????????????????????")
                if archived_order:
                    archived_order.active = True

        super(ProductTmpltInherit, self).toggle_active()        
Avatar
Discard
Best Answer

Hi, may I know is there a solution for this?

Avatar
Discard
Best Answer

Hello rehan,

Try these

    @api.multi

    def toggle_active(self):
        for rec in self:
            if rec.active:
                rec.product_variant_ids.mapped('orderpoint_ids').write({'active':False})
            else:
                rec.product_variant_ids.mapped('orderpoint_ids').filtered(lambda x: x.active == False).write({'active':True})
         super(ProductTmpltInherit, self).toggle_active()   
Avatar
Discard
Author

thank you pal, but unfortunately, it can't work.. i dunno why this is cant work