How can I enhance my development cycle in Odoo to get more results
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Бухгалтерия
- Склад
- PoS
- Project
- MRP
Этот вопрос был отмечен
I found that 'creating templates' using the jinja2 library is a nice solution
for example, I created the following template to create a view for any class
I pass to the template a dictionary with the appropriate values and get the result, I then adjust the result for the specific need
from jinja2 import Template
template = """
<record id="view_{{class_name|replace('.','_')}}_{{type}}" model="ir.ui.view">
<field name="name">{{class_name}}.form</field>
<field name="model">{{class_name}}</field>
<field name="arch" type="xml">
<{{type}} string={{view_title}}>
{%- if type=='form' %}
<sheet>
<group>
{%- endif %}
{%- for fld in fld_list %}
<field name="{{fld}}"/>
{%- endfor %}
{%- if type=='form' %}
</group>
</sheet>
{%- endif %}
</{{type}}>
</field>
</record>
"""
t = Template(template)
params = {
'view_title': 'View Example',
'type': 'tree', #change this to 'form' to get the 'form' version of the output
'class_name': 'my.class.name',
'fld_list': ['field1', 'field2', 'field3' ],
}
print t.render(params)
I posted this to share idea and to get more suggestions for more enhancements
if you know links for simplified examples then this will be great
Thx in advance for your valuable comments and suggestions
It's bad to use templates inside your code. You should separate templates from logic to keep your code organized. This is a design pattern called "Model-Controller-Template" or MVT (like MVC "Model-View-Controller").
My aim is to build a tool that helps me create my models, views, actions, ... faster. I found that templates are useful for that purpose. I posted my example to assure this.
I found the following module https://apps.openerp.com/apps/modules/8.0/builder/, but I think it is more far than what I need, I need some simpler examples, could anyone help me?
any comments ?
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
РегистрацияRelated Posts | Ответы | Просмотры | Активность | |
---|---|---|---|---|
|
0
окт. 25
|
3 | ||
|
2
окт. 25
|
5475 | ||
Delivery Note Management
Решено
|
|
2
окт. 25
|
470 | |
POS receipt template V19
Решено
|
|
2
окт. 25
|
581 | |
|
1
окт. 25
|
592 |