我必须在Odoo 8中将Purchase Order Line设置为可编辑。目前,Purchase.Order Model中的字段order_line具有以下修饰符:
'order_line': fields.one2many('purchase.order.line', 'order_id', 'Order Lines',
states={'approved':[('readonly',True)],
'done':[('readonly',True)]},
copy=True)
因此,如果获得批准或完成,州是只读的。我想删除它。我在下面尝试过:
<field name="order_line" position="attributes">
<attribute name="readonly">0</attribute>
</field>
此外,
<xpath expr="//field[@name='order_line']" position="attributes">
<attribute name="readonly">0</attribute>
</xpath>
但它不起作用。
请帮忙
谢谢,
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)
我如上所述覆盖了字段order_line,但没有任何反应
答案 0 :(得分:7)
只需继承模型并再次定义字段以覆盖它,然后您就可以完全删除states
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)