找不到模型:purchase.requisition odoo 11

时间:2019-09-18 11:41:25

标签: odoo odoo-11

我正在尝试继承模型purchase.requisition表格。我想将页面“产品”的字符串更改为“项目”。

这是我的代码:

    <record id="purchase_requisition_inherited_view_form" model="ir.ui.view">
        <field name="name">purchase.requisition.inherit.view.form</field>
        <field name="model">purchase.requisition</field>
        <field name="inherit_id" ref="purchase_requisition.view_purchase_requisition_form"/>
        <field name="arch" type="xml">
            <xpath expr="//page[1]" position="attributes">
                <attribute name="string">Items</attribute>
            </xpath>
        </field>
    </record>

当我运行服务器时,出现此错误:

Model not found: purchase.requisition

Error context:
View `purchase.requisition.inherit.view.form`
[view_id: 1267, xml_id: n/a, model: purchase.requisition, parent_id: 1259]
None" while parsing /odoo11/custom/addons/test/views/purchase.xml:151, near
<record id="purchase_requisition_inherited_view_form" model="ir.ui.view">
        <field name="name">purchase.requisition.inherit.view.form</field>
        <field name="model">purchase.requisition</field>
        <field name="inherit_id" ref="purchase_requisition.view_purchase_requisition_form"/>
        <field name="arch" type="xml">
            <xpath expr="//page[1]" position="attributes">
                <attribute name="string">Items</attribute>
            </xpath>
        </field>
    </record>

更多详细信息:

        2019-09-18 11:26:10,353 15666 ERROR test odoo.modules.registry: Failed to load           registry
Traceback (most recent call last):
  File "/odoo11/odoo11-server/odoo/models.py", line 1037, in _validate_fields
    check(self)
  File "/odoo11/odoo11-server/odoo/addons/base/ir/ir_ui_view.py", line 342, in _check_xml
    self.postprocess_and_fields(view.model, view_doc, view.id)
  File "/odoo11/odoo11-server/odoo/addons/base/ir/ir_ui_view.py", line 1009, in postprocess_and_fields
    self.raise_view_error(_('Model not found: %(model)s') % dict(model=model), view_id)
  File "/odoo11/odoo11-server/odoo/addons/base/ir/ir_ui_view.py", line 519, in raise_view_error
    raise ValueError(message)
ValueError: Model not found: purchase.requisition

Error context:
View `purchase.requisition.inherit.view.form`
[view_id: 1268, xml_id: n/a, model: purchase.requisition, parent_id: 1259]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/odoo11/odoo11-server/odoo/tools/convert.py", line 745, in parse
    self._tags[rec.tag](rec, de, mode=mode)
  File "/odoo11/odoo11-server/odoo/tools/convert.py", line 655, in _tag_record
    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)
  File "/odoo11/odoo11-server/odoo/addons/base/ir/ir_model.py", line 1504, in _update
    record = record.create(values)
  File "/odoo11/odoo11-server/odoo/addons/base/ir/ir_ui_view.py", line 408, in create
    return super(View, self).create(self._compute_defaults(values))
  File "/odoo11/odoo11-server/odoo/models.py", line 3417, in create
    self._fields[key].determine_inverse(record)
  File "/odoo11/odoo11-server/odoo/fields.py", line 1084, in determine_inverse
    getattr(records, self.inverse)()
  File "/odoo11/odoo11-server/odoo/addons/base/ir/ir_ui_view.py", line 273, in _inverse_arch
    view.write(data)
  File "/odoo11/odoo11-server/odoo/addons/base/ir/ir_ui_view.py", line 424, in write
    return super(View, self).write(self._compute_defaults(vals))
  File "/odoo11/odoo11-server/odoo/models.py", line 3121, in write
    self._write(old_vals)
  File "/odoo11/odoo11-server/odoo/models.py", line 3292, in _write
    self._validate_fields(vals)
  File "/odoo11/odoo11-server/odoo/models.py", line 1041, in _validate_fields
    raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))
odoo.exceptions.ValidationError: ('Error while validating constraint\n\nModel not found: purchase.requisition\n\nError context:\nView `purchase.requisition.inherit.view.form`\n[view_id: 1268, xml_id: n/a, model: purchase.requisition, parent_id: 1259]', None)

我不知道为什么Odoo无法找到模型。

对于那些不知道在哪里可以找到模型的人:

  1. 打开购买模块
  2. 转到设置
  3. 确保您在购买协议上打勾
  4. 然后,模型菜单出现在“购买”->“购买协议”下

谢谢..

PS:我正在使用odoo11企业版。

0 个答案:

没有答案