Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
2 Besvarelser
3099 Visninger

This is the custom model:

class stock_info(models.Model):
_name = 'stock_info.stock'
_description = 'stock_info.stock_info' 
 
product_id = fields.Many2one('product.product', string='Product', store=True)
categ_id = fields.Many2one(related="product_id.categ_id")
# hsn_code = fields.Char(related="product_id.l10n_in_hsn_code", readonly=True)

taxes = fields.Char(related="product_id.taxes_id.display_name", readonly=True, store=True)
 
When executing I am facing this error:
"Field taxes_id referenced in related field definition stock_info.stock.taxes do not exist."
Despite multiple changes to my code, and changing the related attribute, I am unable to make it work.
All I want to do is to display the product's Name, taxes, MRP in my custom module.

Thank you.

Avatar
Kassér
Forfatter Bedste svar

This is the error I am getting:
ValueError: Wrong @depends on '_compute_taxes' (compute method of field stock_info.stock.taxes). 
Dependency field 'taxes_id' not found in model product.product.

Avatar
Kassér
Bedste svar

Hello Madhav Parikh,

You can not iterate through multiple models using related attribute. To achieve this, you need to make this field compute like below.

from odoo import api

taxes = fields.Char(compute="_compute_taxes", store=True)

@api.depends("product_id.taxes_id.display_name")
def _compute_taxes(self):
for rec in self:
rec.taxes = rec.product_id.taxes_id.display_name

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
1
mar. 21
2391
0
aug. 25
5587
4
maj 24
5180
1
apr. 23
1862
3
dec. 22
6964