gpt4 book ai didi

python - 在 odoo 中出现这样的错误

转载 作者:行者123 更新时间:2023-12-01 03:42:38 25 4
gpt4 key购买 nike

TypeError: cannot convert dictionary update sequence element #0 to a sequence

我的代码

@api.model
def action_purchase_order(self):
rec= self.env['purchase.order'].create({
'partner_id' : self.vendors,
'store_id' : self.store_id,
'purchase_order_type' : self.order_type,
'date_order' : self.date_order,
'product_id' : self.product_id,
'date_planned' : self.date_order,
'product_qty' : self.name,
'brand_id' : self.brand_id,
'product_id' : self.product_id,
'part_number': self.part_number,
'date_planned' : self.date_order,
'product_qty' : self.quantity_no,

})

return rec

通过按钮访问..

最佳答案

对按钮操作使用@api.multi装饰器,当您只关心模型而不关心它包含的字段值时使用api.model

@api.multi
def action_purchase_order(self):
rec= self.env['purchase.order'].create({
'partner_id' : self.vendors,
'store_id' : self.store_id,
'purchase_order_type' : self.order_type,
'date_order' : self.date_order,
'product_id' : self.product_id,
'date_planned' : self.date_order,
'product_qty' : self.name,
'brand_id' : self.brand_id,
'part_number': self.part_number,

})

return rec

来自 docs

openerp.api.multi(method)

Decorate a record-style method where self is a recordset. The method typically defines an operation on records.

openerp.api.model(method)

Decorate a record-style method where self is a recordset, but its contents is not relevant, only the model is.

关于python - 在 odoo 中出现这样的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39330614/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com