I have two objects, related by a Many2one relationship. articles can have many article_image records associated with them.
Everything is in place to create article_images and I can link them back to articles in the article_image form. This works great. (Many2one)
But when I'm looking at the article's form, I want to see the linked article_images. (One2many)
I can't seem to get this to work, and keep getting transient module states were reset errors.
Here is my code:
from odoo import fields, models
class MKBArticleImage(models.Model):
_name = "mkb.article_image"
_description = "Knowlege Base Article Images"
article_image_description = fields.Char(string='Description',required=True)
article_image_image = fields.Image(string='Image',required=True)
related_article = fields.Many2one(string="Article",required=True,comodel_name='mkb.article')
class MKBArticle(models.Model):
_name = "mkb.article"
_description = "Knowlege Base Article"
article_number = fields.Char(string='Article #',required=True)
article_description = fields.Char(string='Description',required=True)
article_details = fields.Text(string='Details',required=True)
article_type = fields.Selection(
string='Type',
selection=[('problem_solution', 'Problem/Solution'), ('how_to', 'How-to'), ('hint_or_tip', 'Hint/Tip'), ('reference', 'Reference'), ('process_procedure', 'Process Procedure')],
help="Used to separate Articles.")
related_article = fields.One2many(string="Image Links",comodel_name='mkb.article_image')
(*** the last line causes the error ***)