How to make one2many field readonly depends on other field ?

<xpath expr="//field[@name='order_line']" position="attributes">

                <attribute name="attrs">{'readonly':[('state','in',['done','cancel','sale'])]}</attribute>

</xpath>