Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2609 Prikazi

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
Opusti
Related Posts Odgovori Prikazi Aktivnost
1
avg. 22
5674
0
jul. 20
2838
2
jul. 25
4603
1
jan. 25
6013
2
dec. 24
7762