简体   繁体   English

在向导中未调用功能字段

[英]Function field not getting called from within wizard

In openerp v7 I'm trying to add a field to the stock partial picking view wizard, in the list of products. 在openerp v7中,我试图在产品列表中的库存部分拣配视图向导中添加一个字段。 This wizard gets shown when you receive a stock move. 当您收到库存变动时,将显示此向导。

However, my function isn't even getting called, even though the field's string shows up. 但是,即使显示了字段的字符串,我的函数甚至都没有被调用。 The logging statement never shows up in the server log. 日志记录语句从不显示在服务器日志中。 Is this a bug? 这是错误吗?

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),
    }

接收产品向导

So I never figured out why the function wasn't getting called, but I was able to get it working. 所以我从来没有弄清楚为什么没有调用该函数,但是我能够使其正常工作。

It looks like the data is actually passed to the wizard in _partial_move_for, which is inside of stock_partial_picking.py. 看起来数据实际上已传递到stock_partial_picking.py内部的_partial_move_for中的向导中。 By overriding it, I was able to normal fields inside of the wizard. 通过覆盖它,我能够在向导内部正常显示字段。

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'),
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM