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

According to the documentation (https://www.odoo.com/documentation/15.0/developer/reference/backend/orm.html?highlight=onchange#odoo.api.onchange

 Warning

It is not possible for a one2many or many2many field to modify itself via onchange. This is a webclient limitation - see #2693.

But does that also mean i cannot change a field on one of the objects in the m2m relation ?

I would like to add a tag to an object coming into the many2many and removing the tage when it is removed from the m2m field.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello Jaco Waes


First of all Add M2M field in the model and create onchange method in the purchase order line model.

Please find Example in Comment.

I hope This will help you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

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

Please used this example.

class PurchaseOrdrLine(models.Model):
_inherit = 'purchase.order.line'

@api.onchange('product_id')
def m2m_product_onchange(self):
Your Code........

pol_m2m_ids = fields.Many2many('purchase.order.line', string='M2M Ids')

<field name="pol_m2m_ids" widget="one2many">
<tree editable="bottom">
<field name="product_id"/>
<field name="name"/>
<field name="product_uom_category_id"/>
</tree>
</field>

Câu trả lời hay nhất

This means that you cannot define an onchange function for onemany and many2many fields. That is you cannot trigger any function when there is a change in onemany and many2many fields.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 5 25
503
4
thg 5 25
1813
2
thg 5 25
1962
1
thg 2 25
5245
3
thg 12 24
1772