← Back to team overview

credativ team mailing list archive

[Bug 1260372] Re: [7.0][trunk] Reference field and module dependency

 

I am not sure if you are refering to the workaround #1 by Yann Papouin
(yann-papouin) or #3 by Stefan Rijnhart?

What worked for me was a combination of #3 (adding the following to openerp-server.conf):
[openupgrade]
 forced_deps = {'crm': ['sale']}

and adding sale as a dependency to crm in __openerp__.py as seen in the
attached patch.

I had tried forced_deps only first and it did not work. Later I tried it
with the patch but without forced_deps and it seems to work as well.

I will check it out once I have cleared a few other roadblock but I
wanted to leave this comment nonetheless in case I forget about it again
;)

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

Title:
  [7.0][trunk] Reference field and module dependency

Status in OpenUpgrade Server:
  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-server/+bug/1260372/+subscriptions


References