This question has been flagged
4425 Views

I am using Odoo 12 and have the following models:

class modelA(models.Model):
    _name="mymodule.modela"
    task = fields.Char("Task", size=30, required=True)
    document_id = fields.Many2one('mymodule.modelb','Documents')

   

class modelB(models.Model):
    _name="mymodule.modelb
    name = fields.Char('Documents', required=True)
    document_number = fields.Integer('Document Number', required=True)
    task_ids = fields.One2many('mymodule.modela','document_id')

   
When I am filling data on "modelB", I only have to fill the "name", "document_number" and when I click on "Add an Item" (for the task_ids) I just have to enter "task" value.

The "document_id" is automatically filled by Odoo because there is a relation between 2 models.

This is working fine and I don't even need to show the "document_id" to the user because Odoo fills it automatically.

My problem is that I need to override the "create method" on the "modelA" pop-up form.

For doing that, I need to get the "document_id" value on the "modelA" form view and I am unable to do it.

So, when I click on "Add an Item", I need to get the "document_id" value passed from "modelB" to "modelA" pop-up form.

How can I achieve that?

Thank you all in advance

Avatar
Discard