← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 661249] [NEW] [V5] one2many_list context not passed to orm

 

Public bug reported:

tried to define

<field
            attrs="{ 'readonly':'0', 'readonly': [('state','!=','in_production')]} "
            colspan="4"
            name="move_created_ids"
            nolabel="1"
            widget="one2many_list"
            editable="bottom"
 context="{'form_view_ref':'chricar_stock_weighing.chricar_weighing_form_view','tree_view_ref':'chricar_stock_weighing.chricar_weighing_tree_view'}"
              />

looking into ./osv/orm.py
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False):
...
        result = {'type': view_type, 'model': self._name}

        ok = True
        model = True
        sql_res = False
        while ok:
            view_ref = context.get(view_type + '_view_ref', False)
            # FIXME  view_ref always False
            print >> sys.stderr , 'view_ref ',view_type, view_ref
            if view_ref:
                if '.' in view_ref:
                    module, view_ref = view_ref.split('.', 1)
                    cr.execute("SELECT res_id FROM ir_model_data WHERE model='ir.ui.view' AND module=%s AND name=%s", (module, view_ref))
                    view_ref_res = cr.fetchone()
                    if view_ref_res:
                        view_id = view_ref_res[0]

it seems that context.get(view_type + '_view_ref', False) never returns the values passed from xml o2m widget context
I get in the log
view_ref  form False
view_ref  tree False

my be I missunderstood the example in 
./addons/sale/sale_view.xml:                           
 <field colspan="4" name="invoice_ids" nolabel="1" context="{'form_view_ref':'account.invoice_form'}"/>

** Affects: openobject-server
     Importance: Undecided
         Status: New

-- 
[V5] one2many_list context not passed to orm
https://bugs.launchpad.net/bugs/661249
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to OpenERP OpenObject.

Status in OpenObject Server: New

Bug description:
tried to define 

<field
            attrs="{ 'readonly':'0', 'readonly': [('state','!=','in_production')]} "
            colspan="4"
            name="move_created_ids"
            nolabel="1"
            widget="one2many_list"
            editable="bottom"
 context="{'form_view_ref':'chricar_stock_weighing.chricar_weighing_form_view','tree_view_ref':'chricar_stock_weighing.chricar_weighing_tree_view'}"
              />

looking into ./osv/orm.py
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False):
...
        result = {'type': view_type, 'model': self._name}

        ok = True
        model = True
        sql_res = False
        while ok:
            view_ref = context.get(view_type + '_view_ref', False)
            # FIXME  view_ref always False
            print >> sys.stderr , 'view_ref ',view_type, view_ref
            if view_ref:
                if '.' in view_ref:
                    module, view_ref = view_ref.split('.', 1)
                    cr.execute("SELECT res_id FROM ir_model_data WHERE model='ir.ui.view' AND module=%s AND name=%s", (module, view_ref))
                    view_ref_res = cr.fetchone()
                    if view_ref_res:
                        view_id = view_ref_res[0]

it seems that context.get(view_type + '_view_ref', False) never returns the values passed from xml o2m widget context
I get in the log
view_ref  form False
view_ref  tree False

my be I missunderstood the example in 
./addons/sale/sale_view.xml:                           
 <field colspan="4" name="invoice_ids" nolabel="1" context="{'form_view_ref':'account.invoice_form'}"/>





Follow ups

References