Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

I need to enhance my development cycle

By
Tarek Mohamed Ibrahim
on 3/26/16, 7:57 AM 398 views

How can I enhance my development cycle in Odoo to get more results

1

Tarek Mohamed Ibrahim

--Tarek Mohamed Ibrahim--
896
| 5 3 7
Gîza, Egypt
--Tarek Mohamed Ibrahim--

I am an old VFP developer on ERP

I have moved to 2p since Nov-2014 and started developing with Python on Odoo.

https://www.linkedin.com/profile/public-profile-settings?trk=prof-edit-edit-public_profile

tibrahim@2p.com.sa

Tarek Mohamed Ibrahim
On 3/26/16, 8:00 AM

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").

Vision Advanced Systems, Anass Ahmed
on 3/27/16, 7:00 PM

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.

Tarek Mohamed Ibrahim
on 3/29/16, 3:16 AM

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?

Tarek Mohamed Ibrahim
on 4/7/16, 8:47 AM

any comments ?

Tarek Mohamed Ibrahim
on 4/9/16, 4:58 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 3/26/16, 7:57 AM
Seen: 398 times
Last updated: 7/21/16, 4:41 PM