Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
1276 Переглядів

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.

Аватар
Відмінити
Автор Найкраща відповідь

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"/>
Аватар
Відмінити
Найкраща відповідь

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.


Аватар
Відмінити
Автор

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.

Related Posts Відповіді Переглядів Дія
2
серп. 25
147
4
лип. 25
491
1
груд. 23
3290
0
вер. 23
3192
1
жовт. 24
3774