Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2604 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 22
5672
0
thg 7 20
2834
2
thg 7 25
4595
1
thg 1 25
6007
2
thg 12 24
7755