Odoo:在采购订单中覆盖状态

时间:2017-12-26 19:29:51

标签: python python-2.7 openerp odoo-9 odoo-10

我已经在采购订单模块中覆盖了州字段并将计算功能添加到该字段,但我遇到了加载屏幕。 The screen

以下是我的示例代码:

_inherit = "purchase.order"

@api.depends('my_field')
def _my_compute_field(self):
    for order in self:
        if not order.my_field:
            order.state = 'draft'

state = fields.Selection([
    ('draft', 'RFQ'),
    ('sent', 'RFQ Sent'),
    ('to approve', 'To Approve'),
    ('purchase', 'Purchase Order'),
    ('done', 'Locked'),
    ('fully', 'PO Closed - Fully Received'),
    ('partial', 'PO Closed - Partial Received'),
    ('cancel', 'Cancelled')        
    ], string='Status', readonly=True, index=True, copy=False, default='draft', store=True, compute='_my_compute_field', track_visibility='onchange')

我得到了这个问题的原因这是我的依赖字段,它是计算字段并设置存储=真。

在我尝试将字段设置为store = False后,加载屏幕消失但我无法从计算函数中的字段获取值,因为它未保存到db中。

请帮我解决这个问题。

0 个答案:

没有答案