• odoo 清除所有运行数据


    测试odoo,如果需要一个干净的db。经常需要清除掉所有业务数据。做如下操作,较为方便

    1:建立一个服务器动作,动作的python代码入下。 然后新建一个菜单,菜单动作关联到 这个动作。需要清空db,点击这个菜单就OK啦。

     1 to_removes = [
     2         ['procurement.order',],
     3         ['purchase.order.line',],
     4         ['purchase.order',],
     5 
     6         ['stock.quant',],
     7         ['stock.move',],
     8         ['stock.pack.operation',],
     9         ['stock.picking',],
    10         ['stock.inventory.line',],
    11         ['stock.inventory',],
    12         ['stock.quant.package',],
    13         ['stock.quant.move.rel',],
    14         ['stock.production.lot',],
    15         ['stock.fixed.putaway.strat',],
    16         ['mrp.production.workcenter.line',],
    17         ['mrp.production',],
    18         ['mrp.production.product.line',],
    19         ['sale.order.line',],
    20         ['sale.order',],
    21         ['pos.order.line',],
    22         ['pos.order',],
    23 
    24         ['account.voucher.line',],
    25         ['account.voucher',],
    26         ['account.invoice',],
    27         ['account.partial.reconcile',],
    28         ['account.move',],
    29 ]
    30 
    31 def remove_data(cr):
    32         try:
    33             for line in to_removes :
    34                 obj_name = line[0]
    35                 obj = self.pool.get(obj_name)
    36                 if obj and obj._table_exist:
    37                     sql = "delete from %s" % obj._table
    38                     cr.execute( sql)
    39 
    40 
    41         except Exception, e:
    42             raise Warning(e)
    43 
    44         return True
    45 
    46 remove_data(cr,)
  • 相关阅读:
    种类并查集
    51nod 1241 特殊的排序(动态规划)
    NKU 专题一 题解
    51nod 1040 最大公约数之和
    cf #419(div2) C.Karen and Game(贪心)
    BZOJ 2648 SJY摆棋子(KD-Tree)
    BZOJ 4154 [Ipsc2015]Generating Synergy(KD-Tree)
    hdu 2966 In case of failure(KD-tree)
    hdu 6071 Lazy Running(同余最短路)
    hdu 6070 Dirt Ratio(分数规划)
  • 原文地址:https://www.cnblogs.com/alangwansui/p/5898815.html
Copyright © 2020-2023  润新知