Odoo 10 - 为 IrSequence 实例设置下一个序列的值
Odoo 10 - Set the value of next sequence for a IrSequence instance
我需要在 Python 方法中为 IrSequence 模型实例设置序列值。
我的输入值是:
- IrSequence 的 ID(如果使用日期,也可以获取 IrSequenceDateRange 的 ID)。
- 序列中要使用的下一个值的值。
鉴于该 ID 和该值,我如何以编程方式设置下一个值 - 即通过 python 源代码-那个序列?
谢谢,
有两种方法可以获取序列中的下一个值:
1) 给定 id:
next_seq = seq_record.next_by_id(cr, uid, seq_id, context)
2) 给定代码:
next_seq = seq_record.next_by_code(cr, uid, seq_code, context=context)
但是如果你想直接更改数据库值你可以尝试写记录:
seq_rec = self.env[ir_sequence].browse(seq_id)
seq_rec.write({'number_next': your_next_sequence})
希望对您有所帮助
我需要在 Python 方法中为 IrSequence 模型实例设置序列值。
我的输入值是:
- IrSequence 的 ID(如果使用日期,也可以获取 IrSequenceDateRange 的 ID)。
- 序列中要使用的下一个值的值。
鉴于该 ID 和该值,我如何以编程方式设置下一个值 - 即通过 python 源代码-那个序列?
谢谢,
有两种方法可以获取序列中的下一个值:
1) 给定 id:
next_seq = seq_record.next_by_id(cr, uid, seq_id, context)
2) 给定代码:
next_seq = seq_record.next_by_code(cr, uid, seq_code, context=context)
但是如果你想直接更改数据库值你可以尝试写记录:
seq_rec = self.env[ir_sequence].browse(seq_id)
seq_rec.write({'number_next': your_next_sequence})
希望对您有所帮助