0
votes

I have to make Purchase Order Line as editable in Odoo 8. Currently, the field order_line in Purchase.Order Model has modifier as below:

'order_line': fields.one2many('purchase.order.line', 'order_id', 'Order Lines',
                                  states={'approved':[('readonly',True)],
                                          'done':[('readonly',True)]},
                                  copy=True)

So the states is readonly if approved or done. I want to remove this. I tried with below:

<field name="order_line" position="attributes">
     <attribute name="readonly">0</attribute>        
</field>

Also,

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

But It does not work.

Please help

Thanks,

UPDATE:

class PurchaseOrder(models.Model):
'''
classdocs
'''
_name = 'purchase.order'
_inherit = 'purchase.order'

total_cases = fields.Integer('Total Cases', default=None)
appointment_number = fields.Char('Appointment Number', default=None)

order_line = fields.One2many('purchase.order.line', 'order_id', 'Order Lines', copy=True)

I overrided the field order_line as above, But nothing happens

1
Try redefining the field in your module and remove the 'state' part from it.Hardik Patadia
Hi Hardik, This did not workeduser280960

1 Answers

8
votes

Just inherit from the model and define the field again to override it, then you can remove states totally

from openerp import fields, models

class custom_purchase_order(models.Model):
    _inherit = 'purchase.order'

    order_line = fields.One2many('purchase.order.line', 'order_id', 'Order Lines', states={}, copy=True)