Odoo 8 - on_record_write() 未触发库存'state'拣选字段



因此,我正在使用连接器将状态发送给Magento,具体取决于库存的状态。

这是我使用的(启动(函数:

 @on_record_write(model_names = 'stock.picking')
def change_status_sale_order_sp(session, model_name,
                             record_id, vals):
    if session.context.get('connector_no_export'):
        return
    record = session.env['stock.picking'].browse(record_id)

    if "IN" in record.name: #the stock pickings might be to receive products from the supplier, but we want the one for the deliveries to customers
        return
    origin = record.origin        #String containing the sale order ID + the warehouse from where the order is shipped
    so_name = origin.split(':')[0]
    warehouse = origin.split(':')[1]
    status = record.state
    _logger.debug("STOCK PICKING --- Delivery order " + str(record_id) + " was modified : " + str(vals))

我希望在股票上发生更改时调用该功能。贴上记录,因此装饰器on_record_write。

我的问题是:每个写操作都调用该功能(每次修改字段,无论是手动或在服务器端上(。我永远不会得到" vals"参数为{'state':whythestatusis}。为什么那是我错过的?

on_record_write((每次呼叫库存方法时都会调用。

,但状态字段是字段。功能字段,它将根据库存移动设置,因此您将不会在写入阀中获得状态字段。

相关内容