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

For example, I want to modify the domain of `sale.order.order_line`, and I have to copy all code and add the domain:

class SaleOrder(orm.Model):
    _name = _inherit = "sale.order"
    
    _columns = {
        # Copied from the original, but with domain
        'order_line': fields.one2many(
            'sale.order.line', 
            'order_id', 
            'Order Lines', 
            domain=[("optional", "=", False)],
            readonly=True, 
            states={'draft': [('readonly', False)], 
                    'sent': [('readonly', False)]}),
    }

But I want to know if there is any way to just declare what I want to modify, and leave the rest as is. Something similar to:

class SaleOrder(orm.Model):
    _name = _inherit = "sale.order"

    _columns = {
        'order_line': {
            "domain": [("optional", "=", False)],
        }
    }

Is it possible?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

I don't think that is possible. If you create a field that alreasy exists in the original module, you will completely redefine the field. So yes, if you only wanted to add "required=True" to a field, you have to copy the entire field and add that attribute unfortunately.

Perhaps this will be different with the new API, but for now I think it is not possible.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Inheriting attributes from Fields แก้ไขแล้ว
1
ก.พ. 23
8159
2
พ.ค. 22
2951
1
พ.ค. 22
3690
2
เม.ย. 17
3478
[Odoo 14] inheritance doesn't work แก้ไขแล้ว
1
เม.ย. 24
3630