Odoo 8 - on_record_write()没有触发stock.pick上的'state'字段
问题描述:
因此,我使用连接器根据Odoo中stock.picking记录的状态向Magento发送状态。Odoo 8 - on_record_write()没有触发stock.pick上的'state'字段
这里是我使用该功能(的开始):
@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))
我希望当有一个stock.picking记录的变化,因此装饰on_record_write要调用的函数。
我的问题是:在stock.picking记录中,每一次写入操作(每次字段被修改,手动或在服务器端)调用该函数,除非是状态字段。我从来没有将'vals'参数设为{'state':whateverthestatusis}。为什么呢,我错过了什么?
答
on_record_write()会每次调用stock.picking的写入方法时都会调用。
但是状态字段是fields.function字段,它将基于库存移动进行设置,因此您不会在写入val时获得状态字段。