使用python更新所有POS订单

Jeenit Khatri

我正在尝试更新所有POS订单,但是由于我有大约50,000条记录,因此当发生任何错误或强制停止执行时。然后必须更新已执行的记录数,但在中间停止脚本时未存储记录。所以请给我一些解决方案...

我用来更新记录的代码...

@api.multi
def update_all_amount(self):
    for order in self.search([('copy_amount_total', '=', 0)]):
        self._cr.execute("""update pos_order set copy_amount_total=%s where id = %s"""\
                       % (str(order.amount_total), str(order.id)))
            # print "\nupdated amount --- >", order.copy_amount_total, 
    print "success"
Emipro Technologies Pvt。有限公司

只需在每次更新后放置提交,就不会回滚所有已提交的记录。

@api.multi
def update_all_amount(self):
    for order in self.search([('copy_amount_total', '=', 0)]):
        self._cr.execute("""update pos_order set copy_amount_total=%s where id = %s"""\
                       % (str(order.amount_total), str(order.id)))
            # print "\nupdated amount --- >", order.copy_amount_total, 
        self._cr.commit()
    print "success"

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章