콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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

아바타
취소
관련 게시물 답글 화면 활동
1
8월 22
5723
0
7월 20
2914
2
7월 25
4802
1
1월 25
6123
2
12월 24
7897