我制作了自定义模块,可以在product.template表单视图(库存,销售,仓库中的产品)中添加字段,当我尝试时,这些字段不会与产品重复 . 因此,我试图继承并重写该模块的功能副本 .
我的代码:
class PurchaseOrder(models.Model):
_inherit= 'product.template'
@api.onchange('attribute_set_id')
def _onchange_attributes(self):
# SOME CODE HERE
@api.one
def copy(self, default=None):
default = dict(default or {})
default.update({
'weight': float(43),
})
return super(ProductTemplate, self).copy(default)
这些给了我错误:
...
File "/var/www/.local/share/Odoo/addons/11.0/sync2ba2/models/sync2ba_mob.py", line 89, in copy
return super(ProductTemplate, self).copy(default)
NameError: name 'ProductTemplate' is not defined
我也尝试过不同的名称和类型,如product.template,product_template,'product.template',[product.template] .
我试过 changing the name of the class to ProductTemplate 然后收到错误:
...
File "/usr/local/lib/python3.5/dist-packages/odoo-11.0+e.20171006-py3.5.egg/odoo/models.py", line 3833, in <lambda>
@api.returns('self', lambda value: value.id)
AttributeError: 'list' object has no attribute 'id'
我不确定该错误是来自复制功能还是别的 . 无论哪种方式,我想帮助弄清楚我做错了什么 . 这是Odoo 11企业 . 谢谢 .
1 回答
将您的类名更改为ProductTemplate并使用
@api.multi
而不是@api.one