← Back to team overview

openerp-india team mailing list archive

[Bug 929358] Re: OpenERP v6.1 module testing, and possible corrupt __mro__ (method resolution order)

 

Thankyou, Thu, your reply led us directly to what was causing the
problem.  It was (2).  The self referential import, though, had nothing
to do with the class in question.

A simplified structure of the module:

[w_configurator]
    __init__.py
    __openerp__.py
    config_instance.py
    ...
    ...

    [sale]
        __init__.py
        sale.py
        ...
        ...

    [wizard]
        __init__.py
        configurator_wizard_classes.py
        ...
        ...

WC_Sale_Order_Line class, which caused our headaches, is in
[w_configurator/sale/sale.py]

The import statement I removed is in
[w_configurator/wizard/configurator_wizard_classes.py] and it was

    from w_configurator.config_instance import INSTANCE_TYPES,
DEFAULT_INSTANCE_TYPE

(being a dictionary and a string, respectively).

Somehow, we need to import these objects, and obviously they can only be
done by self reference (without restructuring the module).

Are we doing this wrong, or is there a problem in the OpenERP framework
that needs to cater for this situation?

Once again, thankyou so very much,

Richard

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/929358

Title:
  OpenERP v6.1 module testing, and possible corrupt __mro__ (method
  resolution order)

Status in OpenERP Server:
  New

Bug description:
  We have a module called "w_configurator" which is an extension of,
  among other things, sales.  It is currently being used in OpenERP
  v6.0, and we are testing it under v6.1.

  It has a class which uses:

      class WC_Sale_Order_Line(osv.osv):
          _inherit = "sale.order.line"

  and inside this class, it overrides create.  Inside the create method,
  we use:

      super(WC_Sale_Order_Line,self).create(.....

  This gave us some problems, and after a lot of testing we found the
  following.

      self.pool.get('sale.order.line').create(...

  was calling the correct method, but the "super" call was not calling
  the super, rather it was calling itself again!

  Further testing revealed that

      self.__class__.__mro__

  had the following value

      (<class 'openerp.osv.orm.sale.order.line'>,
       <class 'openerp.addons.w_configurator.sale.sale.WC_Sale_Order_Line'>,
       <class 'openerp.osv.orm.sale.order.line'>,
       <class 'w_configurator.sale.sale.WC_Sale_Order_Line'>,
       <class 'openerp.osv.orm.sale.order.line'>,
       <class 'openerp.addons.sale.edi.sale_order.sale_order_line'>,
       <class 'openerp.addons.sale.sale.sale_order_line'>,
       <class 'openerp.osv.orm.Model'>,
       <class 'openerp.osv.orm.BaseModel'>,
       <class 'edi.models.edi.EDIMixin'>,
       <type 'object'>)

  Dropping the database, and installing from scratch did not fix the
  problem.  However, renaming the module and installing seemed to work,
  first time only (dropping the database, and reinstalling the renamed
  module seemed to cause it to fail again).  There was no foolproof way
  we could find of installing the module to either guarantee it would
  fall over or guarantee it would work, other than to say that once it
  fell over, we could not get it to work again using the same module
  name, no matter what sequence we did database dropping, server
  restarting, or anything else we thought might influence the result.
  When the module worked,

      self.__class__.__mro___

  had the following value

      (<class 'openerp.osv.orm.sale.order.line'>,
       <class 'openerp.addons.w_configurator.sale.sale.WC_Sale_Order_Line'>,
       <class 'openerp.osv.orm.sale.order.line'>,
       <class 'openerp.addons.sale.edi.sale_order.sale_order_line'>,
       <class 'openerp.addons.sale.sale.sale_order_line'>,
       <class 'openerp.osv.orm.Model'>,
       <class 'openerp.osv.orm.BaseModel'>,
       <class 'edi.models.edi.EDIMixin'>,
       <type 'object'>)

  What stood out to me, was that <class
  'w_configurator.sale.sale.WC_Sale_Order_Line'> entry in the "corrupt"
  __mro__ is in fact a repeat of <class
  'openerp.addons.w_configurator.sale.sale.WC_Sale_Order_Line'>, but
  lesser qualified.

  When this lesser qualified class is not in the __mro__, everything
  works.  Also, this lesser qualified class stands out compared to the
  rest of the classes listed, due to the fact that it is not fully
  qualified.

  (It is worth noting, that in both cases, printing

      WC_Sale_Order_Line.__mro__

  was the same:

      (<class 'openerp.addons.w_configurator3.sale.sale.WC_Sale_Order_Line'>,
       <class 'openerp.osv.orm.Model'>,
       <class 'openerp.osv.orm.BaseModel'>,
       <type 'object'>)

  
  We have lost many days already, just getting to this point, so any help would be greatly appreciated.

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/929358/+subscriptions


References