Hi catinga:

Here... the problem is not knowing python but knowing OpenERP objects and how 
to manage them...

I will try to give you some clouds about how to understand the code is shown on 
the example 
http://doc.openerp.com/developer/2_First_Module/2_module.html#model-view-controler-architecture

First... when you build a module you have to write the __terp__.py

There you fix some general parameters about your new module. Importants:
        "depends" : ["base"],  --> Modules that have to be installed so your 
new module can work.
        "init_xml" : [], 
        "update_xml" : ["custom_view.xml"], --> Here, the new module is based 
on custom_view, it is adding new functionality to this module.

So if it's custom_view.xml, you have to copy custom.py and begin building your 
new module based on this. 

custom.py has got this structure, so you have to copy exactly the structure and 
modify it:



from osv import osv, fields 

class travel_hostel(osv.osv):
       _name = 'travel.hostel'
       _inherit = 'res.partner'
       _columns = {
           'rooms_id': 
fields.one2many('travel.room', 'hostel_id', 'Rooms'),
           'quality': 
fields.char('Quality', size=16),
       }
       _defaults = {
       }
travel_hostel()


The new module hostel, will have 2 fields, rooms_id that is one2many to rooms. 
So, one hostel will have many rooms. 
And quality will be a simple char type field.

In this case, you also need to define travel_room class that is not shown on 
the example. 

Once you have defined classes you have to define how to show them on the 
application. You have to define the customer interface... 




<openerp>
<data>
------ HERE You define the hostel form. When you open hostels form on form view 
you will see the two fields defined on the class rooms_id and quality
&nbsp; &nbsp; <record>
&nbsp; &nbsp; &nbsp; &nbsp; <field>Hostel</field>
&nbsp; &nbsp; &nbsp; &nbsp; <field>travel.hostel</field>
&nbsp; &nbsp; &nbsp; &nbsp; <field>form,tree</field>
&nbsp; &nbsp; </record>

------ This is a menu entry for travel agency, shown in main menu
&nbsp; &nbsp; <menuitem>

------ This is a menu entry for Hostels, shown in right side when you click 
menu_travel &#40;see the parameter parent = "menu_travel"&#41;
&nbsp; &nbsp; <menuitem>

------ This is a menu entry for rooms, shown in right side like hostels. It's 
also a menu_travel child

&nbsp; &nbsp; <record>
&nbsp; &nbsp; &nbsp; &nbsp; <field>Room</field>
&nbsp; &nbsp; &nbsp; &nbsp; <field>travel.room</field>
&nbsp; &nbsp; &nbsp; &nbsp; <field>form,tree</field>
&nbsp; &nbsp; </record>
&nbsp; &nbsp; <menuitem>

------ This is a menu entry for Singel rooms, shown in right side but it is a 
rooms menu child, so it's shown below it. See parent="menu_travel_room_form" 
parameter.

It shows rooms, but only those whose bed field is set to 1. See domain field 
<field>&#91;&#40;'beds','=',1&#41;&#93;</field>. Domain fields define the query 
WHERE sentence.
&nbsp; &nbsp; <record>
&nbsp; &nbsp; &nbsp; &nbsp; <field>Single Rooms</field>
&nbsp; &nbsp; &nbsp; &nbsp; <field>travel.room</field>
&nbsp; &nbsp; &nbsp; &nbsp; <field>&#91;&#40;'beds','=',1&#41;&#93;</field>
&nbsp; &nbsp; &nbsp; &nbsp; <field>tree,form</field>
&nbsp; &nbsp; </record>
&nbsp; &nbsp; <menuitem>

------ This is a menu entry for double rooms, shown in right side but it is a 
rooms menu child, so it's shown below it. See parent="menu_travel_room_form" 
parameter.

It shows rooms, but only those whose bed field is set to 2. See domain field 
<field>&#91;&#40;'beds','=',2&#41;&#93;</field>. 

&nbsp; &nbsp; <record>
&nbsp; &nbsp; &nbsp; &nbsp; <field>Double Rooms</field>
&nbsp; &nbsp; &nbsp; &nbsp; <field>travel.room</field>
&nbsp; &nbsp; &nbsp; &nbsp; <field>&#91;&#40;'beds','=',2&#41;&#93;</field>
&nbsp; &nbsp; &nbsp; &nbsp; <field>tree,form</field>
&nbsp; &nbsp; </record>
&nbsp; &nbsp; <menuitem>
</data>
</openerp>


Wishing this can help you....

------------------------
Manuales, Videotutoriales de OpenERP en http://www.openerpsite.com




-------------------- m2f --------------------

--
http://www.openobject.com/forum/viewtopic.php?p=32042#32042

-------------------- m2f --------------------


_______________________________________________
Tinyerp-users mailing list
http://tiny.be/mailman/listinfo/tinyerp-users

Reply via email to