You want to force the save of the project.task before opening the popup form of an equipment in a one2many field. Here are a couple of ways you might achieve this:
- JavaScript: You can override the onchange method for the one2many field in JavaScript to force a save before opening the popup. This would require some knowledge of Odoo’s JavaScript framework.
- Python: You can override the write or create method in Python to save the project.task before opening the popup. This would require some knowledge of Odoo’s Python framework.
Here is a sample code snippet for the Python method:
@api.multi
def write(self, vals):
res = super(ProjectTask, self).write(vals)
# Add your logic here to open the popup
return res
And here is a sample code snippet for the JavaScript method:
openerp.module_name = function (instance) {
var _t = instance.web._t;
instance.web.form.One2ManyDataSet.include({
onchange: function (id, fieldname, value) {
var self = this;
return $.when(this._super.apply(this, arguments)).then(function () {
// Add your logic here to open the popup
});
},
});
};
Replace module_name with the name of your module. Also, please note that these are just sample code snippets and might need to be adjusted to fit your specific use case.