测试odoo,如果需要一个干净的db。经常需要清除掉所有业务数据。做如下操作,较为方便
1:建立一个服务器动作,动作的python代码入下。 然后新建一个菜单,菜单动作关联到 这个动作。需要清空db,点击这个菜单就OK啦。
to_removes = [
['procurement.order',],
['purchase.order.line',],
['purchase.order',], ['stock.quant',],
['stock.move',],
['stock.pack.operation',],
['stock.picking',],
['stock.inventory.line',],
['stock.inventory',],
['stock.quant.package',],
['stock.quant.move.rel',],
['stock.production.lot',],
['stock.fixed.putaway.strat',],
['mrp.production.workcenter.line',],
['mrp.production',],
['mrp.production.product.line',],
['sale.order.line',],
['sale.order',],
['pos.order.line',],
['pos.order',], ['account.voucher.line',],
['account.voucher',],
['account.invoice',],
['account.partial.reconcile',],
['account.move',],
] def remove_data(cr):
try:
for line in to_removes :
obj_name = line[0]
obj = self.pool.get(obj_name)
if obj and obj._table_exist:
sql = "delete from %s" % obj._table
cr.execute( sql) except Exception, e:
raise Warning(e) return True remove_data(cr,)