Odoo:全球第一免费开源ERP库龄表的简单实现方法(无需二开)
问题背景
希望查看库龄超过30天的货物,该如何实现?此种简单数据查询需要二开吗?
解决方案
方法一:Stock Quant列表视图增加过滤器
<filter string="库龄超30天" name="stock_warn" domain="[('location_id.usage','=', 'internal'), ('in_date', '<', (context_today() - relativedelta(days=30)).strftime('%Y-%m-%d 00:00:00') ) ]"/>
方法二:增加一个菜单及一个Server Action,Server Action代码如下:
def stock_quant_over30(dd):
action = self.pool['ir.model.data'].xmlid_to_object(cr, uid, 'stock.quantsact')
d = datetime.datetime.now() - datetime.timedelta(days = dd)
res = { 'name': action.name,
'type': action.type,
'target': action.target,
'view_mode': action.view_mode,
'view_type': action.view_type,
'domain': [('in_date', '<', d.strftime("%Y-%m-%d %H:%M:%S"))],
'context': context,
'res_model': action.res_model,
}
return res
action = stock_quant_over30(30)
文章编辑:开源智造(OSCG) - 源自欧洲,业界领先的免费开源ERP专业服务商