Odoo:全球第一免费开源ERP库龄表的简单实现方法(无需二开)

问题背景

Odoo:全球第一免费开源ERP库龄表的简单实现方法(无需二开)

 

希望查看库龄超过30天的货物,该如何实现?此种简单数据查询需要二开吗?

解决方案

方法一:Stock Quant列表视图增加过滤器

1 <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代码如下:
 1 def stock_quant_over30(dd):
 2  action = self.pool['ir.model.data'].xmlid_to_object(cr, uid, 'stock.quantsact')
 3  d = datetime.datetime.now() - datetime.timedelta(days = dd)
 4  res = { 'name': action.name,
 5  'type': action.type,
 6  'target': action.target,
 7  'view_mode': action.view_mode,
 8  'view_type': action.view_type,
 9  'domain': [('in_date', '<', d.strftime("%Y-%m-%d %H:%M:%S"))],
10  'context': context,
11  'res_model': action.res_model, 
12  }
13  return res
14 action = stock_quant_over30(30)

文章编辑:开源智造(OSCG) - 源自欧洲,业界领先的免费开源ERP专业服务商

猜你喜欢

转载自www.cnblogs.com/yangxunbo/p/10428947.html