← Back to team overview

c2c-oerpscenario team mailing list archive

Re: [Bug 778152] Re: [stable 6.0] stock/wizard/stock_partial_picking.py has bad currency determination as uses optional field to determine value with no failsafe

 

Hi Amit,

Hard to describe exactly how to replicate as I have already fixed in my
implementation by just going picking.company_id.currency_id.id - I don't see
the point of having to look at the product_id.  I also don't see the point
of using a different companies currency.  We only use one currency anyway so
maybe this has effects I am unaware of.

Create a product but do not set a company for it.  Set the tracking fields.
Create a PO for the product in another company (or the same one)
Go to the associated picking and split the production lots.
Then process.

But really all you need to do is run the partial_picking wizard for a
product with no company set and for a type of 'in'

The problem is quite obvious

 'currency' : picking.product_id.company_id.currency_id.id,

but as company_id is an optional field, because the company is not set it
returns a Nonetype error.  Perhaps

'currency': picking.product_id.company_id and
picking.product_id.company_id.currency_id.id or
picking.company_id.currency_id.id

is better.


On Mon, May 9, 2011 at 11:22 PM, Amit Parik (OpenERP) <amp@xxxxxxxxxxx>wrote:

> Hello Graeme,
>
> I have checked your issue.
> But I am not able to get your point exactly where you faced the problem.
>
> So would you please elaborate with more information or provide the
> proper steps on this.
>
> Thanks and waiting for your reply!
>
> ** Changed in: openobject-addons
>       Status: New => Incomplete
>
> --
> You received this bug notification because you are a direct subscriber
> of the bug.
> https://bugs.launchpad.net/bugs/778152
>
> Title:
>  [stable 6.0] stock/wizard/stock_partial_picking.py has bad currency
>  determination as uses optional field to determine value with no
>  failsafe
>
> Status in OpenERP Modules (addons):
>   Incomplete
>
> Bug description:
>  The offending function is this one
>
>      def __create_partial_picking_memory(self, picking, pick_type):
>          move_memory = {
>              'product_id' : picking.product_id.id,
>              'quantity' : picking.product_qty,
>              'product_uom' : picking.product_uom.id,
>              'prodlot_id' : picking.prodlot_id.id,
>              'move_id' : picking.id,
>          }
>
>          if pick_type == 'in':
>              move_memory.update({
>                  'cost' : picking.product_id.standard_price,
>                  'currency' : picking.product_id.company_id.currency_id.id
> ,
>              })
>
>  When creating a product company is an optional field.  Especially
>  useful in multicompany, however when looking for currency it uses this
>  field to find it.  Moreover this is incorrect anyhow as new security
>  rules introduced to share partners and products means that it is
>  looking potentially at the wrong company to determine currency for the
>  move.
>
>  If a company is not set, you receive a NoneType error.
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/openobject-addons/+bug/778152/+subscribe
>

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/778152

Title:
  [stable 6.0] stock/wizard/stock_partial_picking.py has bad currency
  determination as uses optional field to determine value with no
  failsafe

Status in OpenERP Modules (addons):
  Incomplete

Bug description:
  The offending function is this one

      def __create_partial_picking_memory(self, picking, pick_type):
          move_memory = {
              'product_id' : picking.product_id.id, 
              'quantity' : picking.product_qty, 
              'product_uom' : picking.product_uom.id, 
              'prodlot_id' : picking.prodlot_id.id, 
              'move_id' : picking.id, 
          }
      
          if pick_type == 'in':
              move_memory.update({
                  'cost' : picking.product_id.standard_price, 
                  'currency' : picking.product_id.company_id.currency_id.id, 
              })

  When creating a product company is an optional field.  Especially
  useful in multicompany, however when looking for currency it uses this
  field to find it.  Moreover this is incorrect anyhow as new security
  rules introduced to share partners and products means that it is
  looking potentially at the wrong company to determine currency for the
  move.

  If a company is not set, you receive a NoneType error.


References