class picking(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(picking, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'get_product_desc': self.get_product_desc,
'get_product_desc_en': self.get_product_desc_en,
'get_product_unit': self.get_product_unit, # 更新函数
'get_location_name': self.get_location_name,
'get_location_dest_name': self.get_location_dest_name,
})
def get_product_unit(self, move_line):
desc = move_line.product_id.uom_id.name or ''
trans_obj = self.pool.get('ir.translation') # 获取翻译对象
trans_ids = trans_obj.search(
self.cr, self.uid,
[('name', '=', 'product.uom,name'),
('res_id', '=', move_line.product_id.uom_id.id)]) # 匹配出翻译的值
if trans_ids and trans_ids[0]:
desc = desc + ' / ' + trans_obj.read(self.cr, self.uid, trans_ids,
['value'])[0]['value']
return desc