值错误:叶中的字段u'field'无效“<延伸叶对象(ctx:)>“Odoo v8”上的:(u'field',u'in',[59])

2024-04-26 03:22:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下方法:

@api.depends('order_lines', 'order_lines.isbn')
def _get_products(self):
    isbn = self.env['product.product']
    for prodtmpl in self.order_lines: 
        isbn |= prodtmpl.isbn
    return isbn

@api.model
def _get_act_window_dict(self, name):
    mod_obj = self.env['ir.model.data']
    result = mod_obj.xmlid_to_object(name)
    if not result:
        result = {
            'view_type': 'form',
            'view_mode': 'tree,form',
            'res_model': 'stock.quant',
            'name': 'Stock On Hand',
            'type': 'ir.actions.act_window',
        }
    else:
        result = result[0].read()[0]
    return result

@api.multi
def action_open_isbn(self):
    isbn = self._get_products()
    result = self._get_act_window_dict('stock.product_open_quants')
    result['domain'] = "[('isbn','in',[" + ','.join(map(str, isbn.ids)) + "])]"
    result['context'] = "{'search_default_locationgroup': 1, 'search_default_internal_loc': 1}"
    return result

在方法get_act_window_dict上,它应该返回数量产品,比如product.template的现有数量

但它让我想到:

^{pr2}$

我试过这样做:

@api.model
def _get_act_window_dict(self, name):
    mod_obj = self.env['ir.model.data']
    result = mod_obj.xmlid_to_object(name)
    if not result:
        result = {
            'view_type': 'form',
            'view_mode': 'tree,form',
            'res_model': 'stock.quant',
            'name': 'Stock On Hand',
            'isbn': 'product_id',
            'type': 'ir.actions.act_window',
        }
    else:
        result = result[0].read()[0]
    return result

isbn作为product_id添加到dict结果中,但结果相同。在

有什么想法吗?在

PS:这是我类上的isbn字段:

    isbn = fields.Many2one('product.product', string="ISBN", domain="[('is_isbn', '=', True)]")

当然,它不是以isbn的形式存在于stock.quant上,但它对product来说是一个很大的问题,所以它应该以某种方式通过。在


Tags: nameselfapimodobjgetmodelreturn
1条回答
网友
1楼 · 发布于 2024-04-26 03:22:49

这条线:

result['domain'] = "[('isbn','in',[" + ','.join(map(str, isbn.ids)) + "])]"

应该是:

^{pr2}$

没有字段isbn在股票数量. 既然isbn是目标产品.产品,我想产品编号是一样的股票数量在

相关问题 更多 >