如何解决计算方法未能分配 product.template 奥多14
尝试将计算添加到添加到“product.template”模型中的智能按钮中的字段时出现此错误。
文件“/usr/lib/python3/dist-packages/odoo/fields.py”,第1026行,在 获得 raise ValueError("Compute method Failed to assign %s.%s" % (record,self.name)) Exception
上述异常是以下异常的直接原因:
回溯(最近一次调用最后一次):文件“/usr/lib/python3/dist-packages/odoo/http.py”,第 639 行,在 _handle_exception return super(JsonRequest,self)._handle_exception(exception) File "/usr/lib/python3/dist-packages/odoo/http.py",line 315,in _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 最好的。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。