İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
1293 Görünümler

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
Vazgeç
Üretici En İyi Yanıt

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
Vazgeç
En İyi Yanıt

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
Vazgeç
Üretici

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.

İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Ağu 25
152
4
Tem 25
494
1
Ara 23
3293
0
Eyl 23
3196
1
Eki 24
3777