Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2608 Tampilan

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
Buang
Post Terkait Replies Tampilan Aktivitas
1
Agu 22
5673
0
Jul 20
2838
2
Jul 25
4601
1
Jan 25
6011
2
Des 24
7760