Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
21671 Lượt xem

I'm developing a custom module, I just started and coding the view I have a context error with my variables, how can I solve this, my view is inherited from product form view

<record id="view_product_form_inherit_property_view_form" model="ir.ui.view">
    <field name="name">property_management_system.property.view.form</field>
    <field name="model">property_management_system.property</field>
    <field name="mode">primary</field>
    <field name="inherit_id" ref="product.product_normal_form_view"/>
    <field name="arch" type="xml">
      <xpath expr="//div[@name='options']" position="inside">
        <div>
          <field name="property_ok"/>
          <label for="property_ok"/>
        </div>
      </xpath>
    </field>
  </record>


My model is inherits from product.product


class Property(models.Model):
    _name = "property_management_system.property"
    _inherit = ["product.product"]
    property_ok = fields.Boolean("Is Property")


I've been searched a lot and not getting answer, so I decide post this, I can't find wheres the problem.

Ảnh đại diện
Huỷ bỏ

Please post your error here, then we can easily find out the issue.

Tác giả

ok let me use the English lang to get it in the language.

Tác giả

I Can't edit my post, don't know why, so, here is the error:

File "/opt/odoo/devodoo/odoo/addons/base/ir/ir_ui_view.py", line 464, in raise_view_error

raise ValueError(message)

ValueError: Field `property_ok` does not exist

Error context:

View `property_management_system.property.view.form`

[view_id: 1363, xml_id: property_management_system.view_product_form_inherit_property_view_form, model: property_management_system.property, parent_id: 1009]

Tác giả Câu trả lời hay nhất

Ok, I find the issue, in the action view I was calling the view with the wrong model.


I change

<field name="res_model">product.product</field>

to

<field name="res_model">property_management_system.property</field>


And it work!


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 24
1673
5
thg 7 24
92977
1
thg 12 23
3072
1
thg 5 22
3695
0
thg 1 21
2227