Skip to Content
Menu
This question has been flagged

hi 
I have a new module . 
on this module i want to create a backorder from a picking .
so my class is like that : 

class PickingProcess(models.Model):
  _inherit = "mail.thread"
_name = 'picking.process'
_description = "picking process ecoparc"
@api.multi
def createbackorder(self, picking_id):
  picking = self.env['stock.picking'].browse(picking_id)
for pack in picking.pack_operation_ids:
  pack.write({'qty_done'1})
  backorder = self.env['stock.backorder.confirmation'].create({'pick_id': picking.id})
  backorder.process()

@api.model
def manage_action(self):
     self.env['picking.process'].createbackorder(MY_PICKING_ID)
       #self.createbackorder(MY_PICKING_ID) do the same ....

@api.onchange('input_action')
def on_change_input_action(self):
if self.input_action == "" :
return
self.manage_action()



when i change my input it calls the method on_change_input_action which call manage_action. In this case the backorder doesn t work correctly . It makes as done the picking with qty 1 but it doesn t create the backorder.

BUT if i call createbackorder() from an other class like that self.env['picking.process'].createbackorder(MY_MPICKING_ID), it works and create correctly the backorder.
Could you explain to me why ? i spent 2 days to understand but i m lost and i didn t find the answer!


Thanks a lot by advance 


Thomas

Avatar
Discard
Related Posts Replies Views Activity
1
Aug 22
4844
0
Jul 20
2207
2
Nov 24
25064
2
May 24
5512
3
Mar 24
4961