在Odoo 10中计算了many2many字段依赖性 [英] Computed many2many field dependencies in Odoo 10

查看:360
本文介绍了在Odoo 10中计算了many2many字段依赖性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 sale.order.line 模型上创建一个新字段.此字段称为 x_all_route_ids ,旨在包含订单行的所有可用 stock.location.route .

I am trying to create a new field on the sale.order.line model. This field is called x_all_route_ids, and is meant to contain all of the available stock.location.route for an Order Line.

它应该为订单行查找 product_id.route_ids product_id.routes_from_categ_ids ,并将它们连接成一组路由.

It should look up the product_id.route_ids and product_id.routes_from_categ_ids for the Order Line, and join them together into a single set of Routes.

我正在尝试通过Odoo UI设置此字段,但遇到与我的依赖关系"有关的错误.

I am trying to set this field up through the Odoo UI, but getting error related to my "Dependencies".

我的依赖项定义为:

product_id, product_id.route_ids, product_id.routes_from_categ_ids

我将Compute定义为:

I have Compute defined as:

for record in self:
    record['x_all_route_ids'] = record.product_id.route_ids

首先,我只是想让该字段显示与product_id.route_ids相同的值,但是它不起作用.保存时,出现以下错误:

To start I am just trying to get the field to show the same value as product_id.route_ids, but it's not working. When I save, I get the following error:

Error while validating constraint

Unknown field u'product_id' in dependency u'product_id'

你知道我在做什么错吗?

Any idea what I'm doing wrong here?

推荐答案

我能够使它正常工作.我认为问题只是UI中出现的一个错误,因为我尝试了很多不同的事情.刷新页面后,以下工作正常:

I was able to get this working. I think the issue was just a bug in the UI that came about because I had been trying so many different things. After refreshing the page, the following worked:

依赖关系= product_id

字段类型= many2many

计算方法:

for record in self:
    full = record.product_id.route_ids | record.product_id.route_from_categ_ids
    record['x_all_route_ids'] = full.filtered('sale_selectable')

这篇关于在Odoo 10中计算了many2many字段依赖性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆