In here when click the add a question there is a popup comes like this (above)
I want to implement this feature to my custom module. can anyone tell how do that or can anyone tell where is the src code for this feature in odoo default survey module.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Apskaita
- Atsarga
- PoS
- Project
- MRP
This question has been flagged
To implement the feature where clicking "Add" opens a popup form, follow these steps:
- Define the Main Model:
Create a model with a One2many field pointing to the related model.
from odoo import models, fields, api
class MainModel(models.Model):
_name = "main.model"
_description = "Main Model"
name = fields.Char(string="Name", required=True)
related_ids = fields.One2many('related.model', 'main_model_id', string="Related Records")
- Define the Related Model:
Create the related model with a Many2one field pointing back to the main model.
class RelatedModel(models.Model):
_name = "related.model"
_description = "Related Model"
main_model_id = fields.Many2one('main.model', string="Main Model", required=True, ondelete='cascade')
name = fields.Char(string="Name", required=True)
description = fields.Text(string="Description")
- Define the Views:
Define the form and tree views for both models. Ensure the One2many field uses the correct widget.
widget="one2many_list"
By following these steps, you will have a popup form to add related records to the main model, similar to the feature in the Odoo survey module.
Thank you so much !. It worked
but there is another problem, I am making a custom survey module and after using the above widget you mentioned, it gives a popup, but the problem is that pop up is the same as the odoo default survey module's popup. but I didn't install the default survey module . but in my project location the src code of the survey module has exist.
Can we get a my module's related form view or a custom view for the popup instead of default popup's view
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Registracija