Skip to Content
Menu
This question has been flagged
1 Reply
2154 Views

Hi community, 

I tried to run a function (in odoo10) when the attribute "route_id" (in sale.order.line) is changed but nothing happens. Here my code : 

file sale_order.py

class saleOrder(models.Model):
    _inherit = 'sale.order'
    
    @api.multi
    @api.depends("order_line")
    def _compute_products(self):
        _logger.error('@@@@@@@@@')

def action_change_route_id(self):
    for line in self.order_line
        line.route_id = 3

class SaleOrderLine(models.Model):
    _inherit = 'sale.order.line'
    
    @api.onchange("route_id") #also tried with @api_depends("route_id")
    def on_change_route_id(self):
    _logger.error('________')
    self.order_id._compute_products()

I don't see the logs message, if somebody can help me ? 

Thank you 

Avatar
Discard
Best Answer

Hi, try to rename your function to : _onchange_route_id ,

or inherit this function : _onchange_product_id_check_availability like this:

@api.onchange('product_uom_qty','product_uom','route_id')

def _onchange_product_id_check_availability(self):
    super(SaleOrderLine,self)._onchange_product_id_check_availability()
     """  Write your code here """




Avatar
Discard
Related Posts Replies Views Activity
2
Nov 24
25098
2
May 24
5521
3
Mar 24
4964
0
Mar 24
264
3
Feb 24
11421