Is it possible to put a custom many2one field inside a custom one2many list. I would like a table that have an add item button and a row will appear with the many2one drop down. Like when you add items in Journal entry. Im trying this in Odoo 10.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- Project
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
My problem is i get this error
Error while validating constraint
Field `port_id` does not exist
Error context:
View `product.template.common.form`
[view_id: 299, xml_id: product.product_template_form_view, model: product.template, parent_id: n/a]
I added this in EditForm View
<field name="port_ids" nolabel="1">
<tree string="Ports" editable="bottom">
<field name="port_id" />
</tree>
</field>
And this is my model
from odoo import models, fields, api
class Ports(models.Model):
_name = 'ports.ports'
name = fields.Char(required=True)
description = fields.Text()
product_tmpl_id = fields.Many2one(
'product.template', 'Product Template',
index=True, ondelete='cascade')
class product_template(models.Model):
_inherit = "product.template"
port_ids = fields.One2many('ports.ports', 'product_tmpl_id', 'Ports')
port_id = fields.Many2one('ports.ports', string='Port')
Hi,
There is no issues in adding a many2one field inside a one2many field. If you take the case of the sale order line(one2many field) in sales form, you can see the product field is a Many2one field which inside the one2many field.
For adding one2many fields to your form you can check this video: How to Add One2many Fields In Odoo
Thanks
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อRelated Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
---|---|---|---|---|
|
1
ธ.ค. 19
|
9360 | ||
|
1
มี.ค. 15
|
8270 | ||
odoo onchange function on one2many field
แก้ไขแล้ว
|
|
3
ต.ค. 22
|
20707 | |
|
2
ก.ค. 18
|
8003 | ||
|
0
เม.ย. 17
|
6399 |