我正在尝试做一个“每月”的经常性账单,即: - test_months,是要账单的月数;- 行数应为 = to test_months;
因此,每当 test_months onchange 时,我试图获取“行数量”更新,但所有订单行都被删除?
我的代码:
class test_sale_order_line(osv.osv): _name = 'sale.order.line' _inherit = 'sale.order.line'
def _test_product_uom_qty_line(self, cr, uid, ids, field_name, arg, context=None):
res = {}
if context is None:
context = {}
if not test_months:
test_months = 1
for line in self.browse(cr, uid, ids, context=context):
res = { 'product_uom_qty': 0.0 }
res['product_uom_qty'] = test_months
return res
_columns = {
'product_uom_qty': fields.function(_test_product_uom_qty_line, string='Quantity', digits_compute= dp.get_precision('Product UoS'), required=True, readonly=True, states={'draft': [('readonly', False)]}),
}
test_sale_order_line()