所以我使用连接器向Magento发送状态,具体取决于Odoo中stock.picking记录的状态。
这是我用于此的(开始)函数:
@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}。为什么,我错过了什么?
答案 0 :(得分:0)
on_record_write()将在每次调用stock.picking的write方法时调用。
但状态字段是fields.function字段,它将根据库存移动进行设置,因此您不会在写入的val中获得状态字段。