[英]Compute method failed to assign product.template . Odoo 14
嘗試將計算添加到添加到“product.template”模型中的智能按鈕中的字段時,出現此錯誤。
文件“/usr/lib/python3/dist-packages/odoo/fields.py”,第 1026 行,在get raise ValueError("Compute method failed to assign %s.%s" % (record, self.name)) 異常
上述異常是以下異常的直接原因:
回溯(最近一次調用):文件“/usr/lib/python3/dist-packages/odoo/http.py”,第 639 行,在 _handle_exception 中返回 super(JsonRequest, self)._handle_exception(exception) 文件“/usr/ lib/python3/dist-packages/odoo/http.py”,第 315 行,在 _handle_exception 中從 new_cause ValueError 引發 exception.with_traceback(None):計算方法無法分配 product.template(33,).qty
請問怎么了? 任何幫助? 這是我的代碼:
<record id="view_product_test" model="ir.ui.view">
<field name="name">view_product_test</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='action_open_quants']" position="before">
<button class="oe_stat_button"
name="my_action"
icon="fa-cubes"
type="object" attrs="{'invisible':[('type', '!=', 'product')]}">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field name="qty" widget="statinfo" nolabel="1" class="mr4"/>
</span>
<span class="o_stat_text">Qty</span>
</div>
</button>
</xpath>
</field>
</record>
class ProductTemplate(models.Model):
_inherit = "product.template"
qty = fields.Float('Qty', compute='test')
def test(self):
_logger.info('--------------')
您需要在計算方法中進行分配。 當方法為空時,您希望 Odoo 做什么?
至少提供一些東西:
def test(self):
for record in self:
record.qty = 0.0
編輯:是的,錯誤消息不是 Odoo 最好的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.