quarta-feira, 2 de julho de 2014

Odoo - View



  • from openerp.osv import fields,osv
    from openerp import tools
           
     class x_pttstl_report_parent(osv.osv):
        _name = "x_pttstl_report_parent"
        _description = "tree map"
        _auto = False
        _columns = {
            'tuyennr_parent': fields.char('parent', size=128, readonly=True),
            'tendd': fields.char('child', size=128, readonly=True),
           }
        _order = 'tuyennr_parent,tendd'
        def init(self, cr):
            tools.drop_view_if_exists(cr, 'x_pttstl_report_parent')
            cr.execute(""" create or replace view x_pttstl_report_parent AS (
                   select 
                       nrprt.id as id,
                       nrprt.x_tendd_tuyennr_parent as tuyennr_parent,
                       nr.x_tendd as tendd
                    from 
                        x_pttstl_tuyennr nr
                    join 
                        x_pttstl_tuyennr_parent nrprt on (nrprt.id = nr.x_tuyennr_tuyennr_parent_id)
                    group by 
                        nrprt.id,tendd_tuyennr_parent,tendd
                        )
            """)
     
    x_pttstl_report_parent()
     
      model="ir.ui.view" id="x_pttstl_report_parent_tree_view">
         name="name">x_pttstl_report_parent.tree
  • > name="model">x_pttstl_report_parent> name="arch" type="xml"> string="Tree map" version="7.0"> name="tuyennr_parent"/> name="tendd"/> > > >   model="ir.ui.view" id="x_pttstl_report_parent_form_view"> name="name">x_pttstl_report_parent.form> name="model">x_pttstl_report_parent> name="arch" type="xml"> string="So do cay" version="7.0"> name="tuyennr_parent"/> name="tendd"/> > > >
     
      model="ir.actions.act_window" id="action_pttstl_report_parent">
      name="name">Tree map
    > name="res_model">x_pttstl_report_parent> >
     
      name="Map" parent="pttstl_menu" id="vanhanh_menu"/>   
     name="Tree" parent="vanhanh_menu" id="tree_menu" action="action_pttstl_report_parent"/>
     
     
    Fonte:   http://sajjadhossain.com/2013/06/30/openerp-7-creating-report-using-sql-query/