← Back to team overview

openerp-india team mailing list archive

[Bug 1244544] [NEW] Loosing context in some methods

 

Public bug reported:

Hello,

In mrp module we have some methods which don't pass the context. For
example force_production:

def force_production(self, cr, uid, ids, *args):
        """ Assigns products.
        @param *args: Arguments
        @return: True
        """
        pick_obj = self.pool.get('stock.picking')

        ##### !!! FIXME: here context isn't passed, but force_assign method in stock.picking has the attribute 'context'!!! #####
        pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)])
        return True

That way, if we need to inherit force_assign method of stock.picking, we
also must inherit all the methods which don't pass the context to
force_assign and I think this is very bad practice, because if context
would be passed everywhere, we wouldn't have these problems and it would
be clear, perfect way to inherit only one method that we really need to
inherit.

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

** Description changed:

  Hello,
  
  In mrp module we have some methods which don't pass the context. For
  example force_production:
  
  def force_production(self, cr, uid, ids, *args):
-         """ Assigns products.
-         @param *args: Arguments
-         @return: True
-         """
-         pick_obj = self.pool.get('stock.picking')
+         """ Assigns products.
+         @param *args: Arguments
+         @return: True
+         """
+         pick_obj = self.pool.get('stock.picking')
  
-         ####  FIXME: here context isn't passed, but force_assign method in stock.picking has the attribute 'context'! ####
-         pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)])
-         return True
+         ##### !!! FIXME: here context isn't passed, but force_assign method in stock.picking has the attribute 'context'!!! #####
+         pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)])
+         return True
  
- 
- That way, if we need to inherit force_assign methon of stock.picking, we also must inherit all the methods which don't pass the context to force_assign and I think this is very bad practice, because if context would be passed everywhere, we wouldn't have these problems and it would be clear, perfect way to inherit only one method that we really need to inherit.
+ That way, if we need to inherit force_assign methon of stock.picking, we
+ also must inherit all the methods which don't pass the context to
+ force_assign and I think this is very bad practice, because if context
+ would be passed everywhere, we wouldn't have these problems and it would
+ be clear, perfect way to inherit only one method that we really need to
+ inherit.

** Description changed:

  Hello,
  
  In mrp module we have some methods which don't pass the context. For
  example force_production:
  
  def force_production(self, cr, uid, ids, *args):
          """ Assigns products.
          @param *args: Arguments
          @return: True
          """
          pick_obj = self.pool.get('stock.picking')
  
          ##### !!! FIXME: here context isn't passed, but force_assign method in stock.picking has the attribute 'context'!!! #####
          pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)])
          return True
  
- That way, if we need to inherit force_assign methon of stock.picking, we
+ That way, if we need to inherit force_assign method of stock.picking, we
  also must inherit all the methods which don't pass the context to
  force_assign and I think this is very bad practice, because if context
  would be passed everywhere, we wouldn't have these problems and it would
  be clear, perfect way to inherit only one method that we really need to
  inherit.

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

Title:
  Loosing context in some methods

Status in OpenERP Addons (modules):
  New

Bug description:
  Hello,

  In mrp module we have some methods which don't pass the context. For
  example force_production:

  def force_production(self, cr, uid, ids, *args):
          """ Assigns products.
          @param *args: Arguments
          @return: True
          """
          pick_obj = self.pool.get('stock.picking')

          ##### !!! FIXME: here context isn't passed, but force_assign method in stock.picking has the attribute 'context'!!! #####
          pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)])
          return True

  That way, if we need to inherit force_assign method of stock.picking,
  we also must inherit all the methods which don't pass the context to
  force_assign and I think this is very bad practice, because if context
  would be passed everywhere, we wouldn't have these problems and it
  would be clear, perfect way to inherit only one method that we really
  need to inherit.

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


Follow ups

References