Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
1889 Widoki

For example, I have a custom module:

class CustomModule(models.Model):

​_name = 'custom module'


​custom_char = fields.Char(string="Custom Char")

​product_tmpl_id = fields.Many2one('product.template', string="Product Template", required=True )

​product_template_image_ids = fields.One2many('product.image', 'product_tmpl_id', string="Extra Product Media")


My view for the product_template_image_ids field in my custom module:

field name="product_template_image_ids" mode="kanban" context="{'default_product_tmpl_id': product_tmpl_id}"


File "C:\Odoo\odoo\models.py", line 5250, in _update_cache raise ValueError("Invalid field %r on model %r" % (e.args[0], self._name)) ValueError: Invalid field 'custom_char' on model 'product.template'

It looks like it wants to inherit the fields from my custom model, not take the value from the context.

Is there any solution?

Awatar
Odrzuć

you may forget add dependency in manifest

Autor

Probably not. This is what it looks like:

'depends': ['product', 'website_sale']

Autor Najlepsza odpowiedź

https://codepaste.xyz/posts/B3QjoXws7Y46Ld35A9H2


product_template_image_ids = fields.One2many('product.image', 'product_tmpl_id', string="Extra Product Media")


product_tmpl_id - makes a problem

Is it possible to make some relations to display and edit this field (product_template_image_ids) from my custom module?


I found a solution. It works for me!

product_template_image_ids = fields.One2many(related='product_tmpl_id.product_template_image_ids', string="Product Imagesl", readonly=False)

+ context in view


Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

As per shared code, it seems you have defined the field custom_char inside a new model named: custom module , did you add this field inside any view ? 

ie, error message says that, you have added or you are adding field in the view of product.template model and thus you get this error. 

You can update your question with the view information for more help.

Thanks

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lip 25
1970
2
wrz 23
5850
0
mar 23
2237
19
wrz 20
69842
5
sty 20
4425