Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
3507 Представления

Hi

I want to know how to access stock.quant and make a related field in product.product for that.

I have this:

test_field = fields.Char(string='test', related='stock_quant.location_id)


This gives me a "stock_quant" error. How to access partner name is like this:

test_field = fields.Char(string='test', related='partner_id.name')

How can I find the exact text before the field value I want? like this example (partner_id)?


Thanks


Аватар
Отменить
Лучший ответ

The "partner_id" is a field declared in the current model, it works as a link between this model, and the fields related to the "res.partner" model like "name" in your example
So, in order for the related field to work, you'd need to first have a field "stock_quant", then make your related field.
But in your case, I think that the real issue is the type of the related field. What i'm seeing is you're trying to create a Char field, while the "source field" is "location_id".
Try the following and it would work:

test_field = fields.Many2one(string='test', related='stock_quant.location_id)
Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
мар. 15
3566
2
мар. 15
17234
1
авг. 22
6685
0
мая 17
2938
3
июл. 24
2019