[Trunk/7.0] do_partial function in partial picking wizard doesn't accept a wizard line without move_id

Bug #1172694 reported by Yannick Vaucher @ Camptocamp
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Confirmed
Low
OpenERP R&D Addons Team 2

Bug Description

In addons/stock/stock_partial_picking.py

There is a check if move_id is define, however the partial picking will fail like this:

  File ".../7.0/trunk/parts/syleam/stock_scanner/stock_scanner.py", line 664, in _scenario_save
    exec step.python_code in ld
  File "<string>", line 38, in <module>
  File ".../7.0/trunk/parts/addons/stock/wizard/stock_partial_picking.py", line 212, in do_partial
    partial_data['move%s' % (wizard_line.move_id.id)].update(product_price=wizard_line.cost,
KeyError: 'moveFalse'

I make a MP to fix this

Related branches

description: updated
Changed in openobject-addons:
status: New → Fix Committed
Revision history for this message
Twinkle Christian(OpenERP) (tch-openerp) wrote :

Hello Yannick,

Currently, I am not getting with this enough information. Would you please provide more information or proper steps to reproduce your issue?

Thanks & waiting for you answer.

Changed in openobject-addons:
status: Fix Committed → Incomplete
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Well this is a coding issue.

If you look at the method do_partial_picking in file addons/stock/wizard/stock_partial_picking.py

You will see a check if wizard_line.move_id.id is set or not. And then after the test use wizard_line.move_id.id even if it isn't set. So calling the method without move_id will raise the previous error.

Wether it should use move_id instead of wizard_line.move_id.id or check wizard_line.move_id is not null in case of
(picking_type == 'in') and (wizard_line.product_id.cost_method == 'average')

This is for my specific needs but there is obviously an error in this code part.

I think my solution is the best of the two option as I don't see why it would not be allowed to give an empty wizard_line.move_id to force the creation of a new one in case of product reception.

summary: [7.0] do_partial function in partial picking wizard doesn't accept a
- line without move_id
+ wizard line without move_id
Revision history for this message
Amit Parik (amit-parik) wrote : Re: [7.0] do_partial function in partial picking wizard doesn't accept a wizard line without move_id

Hello Yannick.

If there is no partial move_ids then it will never execute the move_id = wizard_line.move_id.id code as well as
if (picking_type == 'in') and (wizard_line.product_id.cost_method == 'average'):
                partial_data['move%s' % (wizard_line.move_id.id)].update(product_price=wizard_line.cost,
                                                                  product_currency=wizard_line.currency.id)
this also will never execute.

See the code

        for wizard_line in partial.move_ids:
            line_uom = wizard_line.product_uom
            move_id = wizard_line.move_id.id

Another thing move_id = wizard_line.move_id.id both have same value, So your fix didn't fix anything. It works ad it works before.
Also the main thing move_id will never passed as a False, So I am going to close this issue.

Thank you!

Changed in openobject-addons:
status: Incomplete → Invalid
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

move_id is not mandatory on a wizard_line so it can be false.

And as in the for loop we are checking move_id, it is even expected that it can be false.

Thus as explained in MP move_id is set if move_id is false. So at that point move_id <> wizard_line.move_id.id

I set this bug report as incomplete again in case you need more information.

Changed in openobject-addons:
status: Invalid → Incomplete
Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Yannick,

If there is not move_id then for wizard_line in partial.move_ids: this for loop is never execute. I think under the code of this for look will not execute when there is no move_id. So it doesn't matter we check whether its move_id exist or not.

Thanks and waiting for your answer!

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Amit,

You are getting confused by the wizard.move_ids and the wizard_line.move_id

The structure is that way:

wizard (partial)
-- move_ids (wizard_line)
  -- move_id (real move linked in the wizard_line (if set))

In stock.partial.picking:
'move_ids' : fields.one2many('stock.partial.picking.line', 'wizard_id', 'Product Moves'),

In stock.partial.picking.line:
'move_id' : fields.many2one('stock.move', "Move", ondelete='CASCADE'),

So with a wizard_line.move_id == False partial.move_ids won't be null. This mean we will enter in the for loop.

Please look again at the code.

Regards

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for OpenERP Addons because there has been no activity for 60 days.]

Changed in openobject-addons:
status: Incomplete → Expired
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

I reopen it as my last comment was unanswered

Changed in openobject-addons:
status: Expired → New
Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Yannick,

Thanks for detailed discussion.

I have faced the same error my end, But we can produce it explicitly. i.e I have put the move_id on partial_picking_line view.
Then after I have manually removed the move_id from that wizard, then after I faced the same error.

Same kind of error also faced before reproducing this issue see code.
method def _tracking
           if (tracklot.move_id.picking_id.type == 'in' and tracklot.product_id.track_incoming == True) or \
                (tracklot.move_id.picking_id.type == 'out' and tracklot.product_id.track_outgoing == True):

Here also we get the traceback when we removed the move_id manually.

Thank you!

summary: - [7.0] do_partial function in partial picking wizard doesn't accept a
- wizard line without move_id
+ [Trunk/7.0] do_partial function in partial picking wizard doesn't accept
+ a wizard line without move_id
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Don't forget to change your disapprove on the MP

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Yannick,

Thanks for the pointing out!
I have done it.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.