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

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?

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

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 2 23
8166
2
thg 5 22
2951
1
thg 5 22
3695
2
thg 4 17
3493
1
thg 4 24
3630