Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Is there a way to modify a field property without affecting the others?

By
Jairo Llopis
on 7/8/14, 3:55 AM 649 views

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?

0

Ludo - Neobis

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

Ludo - Neobis
On 7/8/14, 8:50 AM

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/8/14, 3:55 AM
Seen: 649 times
Last updated: 3/16/15, 8:10 AM