我正在尝试为某些数据创建历史记录,我需要将one2many值复制到另一个one2many字段中。 问题是我总是只获得最后一条记录
我试图在one2many字段的每一行上循环
def create_action(self):
for agent in self:
for line in agent.local_id:
action_obj = self.env["historiq"]
values = [(0, 0, {'localisation': value.localisation}) for value in line]
historique = {
'date_affectation': str(datetime.datetime.now()),
'nom_agent': agent.agent_id.name,
'post_occupee': agent.poste,
'zone_affecte': values,}
action_ids = action_obj.create(historique)
答案 0 :(得分:0)
是否可以采取任何相关的one2many字段来复制相关的字段?
并且可以显示调用这些函数的位置。