在openerp v7中,我试图在产品列表中向库存部分拣货视图向导添加一个字段。收到库存移动时会显示此向导。
然而,即使字段的字符串出现,我的函数甚至都没有被调用。日志记录语句从不显示在服务器日志中。这是一个错误吗?
class stock_partial_picking_line(osv.TransientModel):
_inherit = "stock.partial.picking.line"
def _product_description(self, cr, user, ids, name, arg, context=None):
_logger.info("inside _product_description")
res = {}
for line in self.browse(cr, user, ids, context=context):
res[line.id] = line.product_id.x_short_description
return res
_columns = {
'product_description': fields.function(_product_description, string='Description', type='char', method=True),
}
答案 0 :(得分:0)
所以我从未弄清楚为什么函数没有被调用,但我能够让它工作。
看起来数据实际上是传递给_partial_move_for中的向导,它位于stock_partial_picking.py中。通过覆盖它,我能够在向导内部的正常字段。
def _partial_move_for(self, cr, uid, move):
partial_move = {
'product_id' : move.product_id.id,
# Add product description
'product_description' : move.name,
'quantity' : move.product_qty if move.state in ('assigned','draft','confirmed') else 0,
'product_uom' : move.product_uom.id,
'prodlot_id' : move.prodlot_id.id,
'move_id' : move.id,
'location_id' : move.location_id.id,
'location_dest_id' : move.location_dest_id.id,
}
return partial_move
# Add the product description to the wizard.
# The values get filled in from stock_partial_picking._partial_move_for
class stock_partial_picking_line(osv.TransientModel):
_inherit = "stock.partial.picking.line"
_columns = {
'product_description': fields.char('Description'),
}