【发布时间】:2021-07-21 05:58:46
【问题描述】:
由于未保存字段“tax_ids_after_fiscal_position”的问题,我尝试使用在 pos.order.line 模型中调用的以下函数更新 One2many 字段 这是我的代码:
class PosOrderLine(models.Model):
_inherit = "pos.order.line"
@api.onchange('product_id')
def _onchange_product_id(self):
self.tax_ids_after_fiscal_position = self.product_id.taxes_id
self.write({'tax_ids_after_fiscal_position': [(4, self.product_id.taxes_id)]})
我收到以下错误:
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 639, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 315, in _handle_exception
raise exception.with_traceback(None) from new_cause
AttributeError: 'account.tax' object has no attribute 'ref'
请问怎么了? 有什么帮助吗? 谢谢。
【问题讨论】:
-
不要使用 Odoo。如果您真的想做一些不涉及太多编码的事情,请使用 Bubble。我曾经专业地使用这些东西。很垃圾。
-
您可以发布文件吗?这似乎不是错误的来源。
-
@Juliana Hill ,哪个文件?
-
它看起来可能与:
self.write({'tax_ids_after_fiscal_position': [(4, self.product_id.taxes_id)]})我不太确定我是否完全记得这一点,但我认为元组的数字值是错误的。
标签: python oop inheritance orm odoo