Skip to Content
This question has been flagged
2 Replies
7615 Views

I have a field email and a field starting_day. I would like starting_day to be required if email has been selected. My model:

class sales_order_line_item_email(osv.Model):
    _name = 'sale.order.line'
    _inherit = 'sale.order.line'
    _columns = {
        'email_chain': fields.many2one(
            'sale.order_email.collection',
            'Email Chain',
            required=False
        ),
        'starting_day': fields.date('Starting Day', required=False),
    }

Avatar
Discard
Best Answer

Hi Kit,

You can achieve your goal using the attrs into view where you have put those fields. You have to put your fields like below into inherited view.

<field name="email_chain" />

<field name="starting_day" attrs="{'required':[('email_chain','!=',False)]}" />

thats it.

Avatar
Discard
Best Answer

Use attrs in your view.

attrs="{'required':[('email_chain', '!=', False)]}"

add this code inside your starting day filed

Avatar
Discard

Hello Deviprasad, Why are you copied my answer ?

OMG by mistake both of us posted same time. To be honest i didn't saw your answer. Sorry

@Deviprasad: Its ok no problem. :) I give you up vote for your answer. You can also do it. Thanks. @Kit : If you feel that my answer is ok for you then accept my answer and give me up vote. Thanks for that.

Related Posts Replies Views Activity
0
Jan 24
303
2
May 23
6643
1
Feb 22
20932
5
Dec 21
14852
0
Dec 20
3590