← Back to team overview

credativ team mailing list archive

[Bug 1260372] [NEW] Reference field and module dependency

 

Public bug reported:

I'm stuck on something really hard.
I experienced this bug while upgrading from 6.1 to 7.0 and the error occurred when upgrading "crm.lead" partners.
A call write is done via model.write(cr, SUPERUSER_ID, row[0], {partner_field: row[1]}).

Since the "crm.lead" model own some stored fields ('day_open,
'day_close', 'state'), their values are computed on write and I don't
know why, but all fields are "get" in _store_set_values.

The problem here is that two references fields exists in the "crm.lead" module:
- 'ref': fields.reference('Reference', selection=crm._links_get, size=128),
- 'ref2': fields.reference('Reference 2', selection=crm._links_get, size=128),

A reference field can be a "sale.order" and that's the problem since
"sale.order" is not loaded when upgrading the crm module (and sale is
not a dependency of crm), so the obj return by pool.get is None in
__getitem__ [orm.py:468]:

elif field_column._type == 'reference':
    if result_line[field_name]:
        if isinstance(result_line[field_name], browse_record):
            new_data[field_name] = result_line[field_name]
        else:
            ref_obj, ref_id = result_line[field_name].split(',')
            ref_id = long(ref_id)
            if ref_id:
                obj = self._table.pool.get(ref_obj)
                new_data[field_name] = browse_record(...)
            else:
                new_data[field_name] = browse_null()
    else:
        new_data[field_name] = browse_null()

It will produced this error:

  File "/openerp/osv/orm.py", line 340, in __init__
    self._table_name = self._table._name
AttributeError: 'NoneType' object has no attribute '_name'

** Affects: openupgrade-addons
     Importance: Undecided
         Status: New

** Description changed:

- I'm stuck one something really hard.
+ I'm stuck on something really hard.
  I experienced this bug while upgrading from 6.1 to 7.0 and the error occurred when upgrading "crm.lead" partners.
  A call write is done via model.write(cr, SUPERUSER_ID, row[0], {partner_field: row[1]}).
  
  Since the "crm.lead" model own some stored fields ('day_open,
  'day_close', 'state'), their values are computed on write and I don't
  know why, but all fields are "get" in _store_set_values.
  
  The problem here is that two references fields exists in the "crm.lead" module:
  - 'ref': fields.reference('Reference', selection=crm._links_get, size=128),
  - 'ref2': fields.reference('Reference 2', selection=crm._links_get, size=128),
  
  A reference field can be a "sale.order" and that's the problem since
  "sale.order" is not loaded when upgrading the crm module (and sale is
  not a dependency of crm), so the obj return by pool.get is None in
  __getitem__ [orm.py:468]:
  
  elif field_column._type == 'reference':
-     if result_line[field_name]:
-         if isinstance(result_line[field_name], browse_record):
-             new_data[field_name] = result_line[field_name]
-         else:
-             ref_obj, ref_id = result_line[field_name].split(',')
-             ref_id = long(ref_id)
-             if ref_id:
-                 obj = self._table.pool.get(ref_obj)
-                 new_data[field_name] = browse_record(...)
-             else:
-                 new_data[field_name] = browse_null()
-     else:
-         new_data[field_name] = browse_null()
+     if result_line[field_name]:
+         if isinstance(result_line[field_name], browse_record):
+             new_data[field_name] = result_line[field_name]
+         else:
+             ref_obj, ref_id = result_line[field_name].split(',')
+             ref_id = long(ref_id)
+             if ref_id:
+                 obj = self._table.pool.get(ref_obj)
+                 new_data[field_name] = browse_record(...)
+             else:
+                 new_data[field_name] = browse_null()
+     else:
+         new_data[field_name] = browse_null()
  
  It will produced this error:
  
-   File "/openerp/osv/orm.py", line 340, in __init__
-     self._table_name = self._table._name
+   File "/openerp/osv/orm.py", line 340, in __init__
+     self._table_name = self._table._name
  AttributeError: 'NoneType' object has no attribute '_name'

-- 
You received this bug notification because you are a member of
OpenUpgrade Committers, which is subscribed to OpenUpgrade Addons.
https://bugs.launchpad.net/bugs/1260372

Title:
  Reference field and module dependency

Status in OpenUpgrade Addons:
  New

Bug description:
  I'm stuck on something really hard.
  I experienced this bug while upgrading from 6.1 to 7.0 and the error occurred when upgrading "crm.lead" partners.
  A call write is done via model.write(cr, SUPERUSER_ID, row[0], {partner_field: row[1]}).

  Since the "crm.lead" model own some stored fields ('day_open,
  'day_close', 'state'), their values are computed on write and I don't
  know why, but all fields are "get" in _store_set_values.

  The problem here is that two references fields exists in the "crm.lead" module:
  - 'ref': fields.reference('Reference', selection=crm._links_get, size=128),
  - 'ref2': fields.reference('Reference 2', selection=crm._links_get, size=128),

  A reference field can be a "sale.order" and that's the problem since
  "sale.order" is not loaded when upgrading the crm module (and sale is
  not a dependency of crm), so the obj return by pool.get is None in
  __getitem__ [orm.py:468]:

  elif field_column._type == 'reference':
      if result_line[field_name]:
          if isinstance(result_line[field_name], browse_record):
              new_data[field_name] = result_line[field_name]
          else:
              ref_obj, ref_id = result_line[field_name].split(',')
              ref_id = long(ref_id)
              if ref_id:
                  obj = self._table.pool.get(ref_obj)
                  new_data[field_name] = browse_record(...)
              else:
                  new_data[field_name] = browse_null()
      else:
          new_data[field_name] = browse_null()

  It will produced this error:

    File "/openerp/osv/orm.py", line 340, in __init__
      self._table_name = self._table._name
  AttributeError: 'NoneType' object has no attribute '_name'

To manage notifications about this bug go to:
https://bugs.launchpad.net/openupgrade-addons/+bug/1260372/+subscriptions


Follow ups

References