Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1226 Vistas

Hi,

We're running Odoo 17e entreprise on-prem.

I'm trying to develop an addon to be able to more easily handle the creation of worksheet templates and worksheet views. 

We're in a situation where we need to recreate our quality worksheets when changes are made to them. The reason behind this is that worksheets need to stay exactly like they were when they were filled and modifying the views retroactively changes the worksheets already completed. 

I was thinking that defining the fields for each worksheet template in xml in a module would save me a lot of time when updating those worksheet templates, as I can create a new model, copy-paste most of the date, make the changes to the views and upload the new version, thus keeping completed worksheet intact while using the new ones in the future.

I'm able to create a new worksheet template by creating a new worksheet.template record, but I'm having trouble figuring out how to add fields to the model created by that new worksheet record.

Is there a good way to do what I'm looking to do and is there a simpler way to keep already completed worksheet intact while making changes to future ones?

Edit: One of the constraint of the project is keeping the module as a data module. Python files are to be avoided.

Avatar
Descartar
Autor Mejor respuesta

I've managed to find a solution:
It is possible to create a field record through XML. In that record, using the XMLID of the worksheet created, it is possible to fetch the model_id of the model linked to the worksheet. Fields can then be added arbitrarily using more field records.

<field name="model_id" model="ir.model" eval="obj().env.ref('module.worksheet_xml_id').id"/>
Avatar
Descartar
Mejor respuesta

Would it work if I will create custom model "module.worksheet_1" with apropriate fields (also with many2one quality.check), views and actions, then create new worksheet.template record linking to id of module.worksheet_1 ? 

My point is to not use worksheet creation method. Just prepare the model in my module and put the link in there.


Avatar
Descartar
Autor

I forgot to add it to the post, but one of the constraint of the project is not using any python code to be able to install the module as a data module, so only XML and JS files.

Publicaciones relacionadas Respuestas Vistas Actividad
4
jul 25
446
1
dic 23
3264
0
sept 23
3172
1
oct 24
3764
5
nov 19
5416