0

我得到错误 ERROR openerp.netsvc: 'sale.order' object has no attribute 'test_onchange_months'

我已经关注了如何在 openERP 7 中添加功能?,但这不起作用。

我的代码

class test_salesOrder(osv.osv):
    _name = 'sale.order'
    _inherit = 'sale.order'

    _columns = {
        'test_years_from': fields.many2one('test.year', 'Years From'),
        'test_years_to': fields.many2one('test.year', 'Years From'),
        'test_months_from': fields.integer('Months From'),
        'test_months_to': fields.integer('Months To'),
        'test_months': fields.integer('Months'),
        'test_dummy': fields.char('TEST Dummy - CHAR', size=64, required=False),
    }

    def test_onchange_months(self, cr, uid, ids, test_months, context=None):
        test_product_uom_qty = test_months
        res = {}

        if context is None:
            context = {}

        if test_product_uom_qty: 
            for order in self.browse(cr, uid, ids, context=context):
                for line in order.order_line:
                    res[line.id] = {'product_uom_qty' : 0}
                    res[line.id]['product_uom_qty'] = test_product_uom_qty

        return res

    def test_onchange_months_from(self, cr, uid, ids, test_months_from, test_months_to, context=None):
        v = {}
        v['test_months'] = test_months_to - test_months_from
        return {'value': v}

    def test_onchange_months_to(self, cr, uid, ids, test_months_from, test_months_to, context=None):
        v = {}
        v['test_months'] = test_months_to - test_months_from
        return {'value': v}

test_salesOrder()
4

1 回答 1

-1

尝试这个,

代替_name = "sale.order.test"

于 2013-10-24T08:15:24.737 回答