有没有一种方法可以使用Python更改选择字段的值,但是我没有找到任何要使用的文档。状态字段是描述治疗状态的字段
我希望做这样的事情:
state=fields.Selection([
('stopped', 'Stopped'),
('wait', 'Wait'),
('finished', 'finished'),
], 'State', readonly=True)
def changeselectionvalue(self,state)
self.state=state #something to do this
请帮助我,我是Tryton的新用户
只需使用write API:
records = Model.search([]) #Get all the records you wan to write.
Model.write(records, {'state': 'new_state'})
或ActiveRecord模式:
self.state = 'new_state'
self.save()
“新状态”必须是选择的内部值之一。
当必须在一堆中更新多个记录时,建议使用第一个记录。
如果您在模型中使用Workflow类的子类,建议您使用@ Workflow.transition(new_state)装饰器来更改记录的状态,因为它仅更新过渡有效的记录。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句