Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
21675 มุมมอง

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.

อวตาร
ละทิ้ง

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

ผู้เขียน

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

ผู้เขียน

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]

ผู้เขียน คำตอบที่ดีที่สุด

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!


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
พ.ย. 24
1675
Change the Position of field in Xpath แก้ไขแล้ว
5
ก.ค. 24
92981
1
ธ.ค. 23
3072
1
พ.ค. 22
3697
0
ม.ค. 21
2229