Skip to Content
Menu
This question has been flagged

I have a custom module that creates a stock.move and stock.move.lines. This is my sample code in creating sm and sml


#create stock.move

        for shrinkage in self:

            vals = {'date': self.date, 'state':'done'}

            if not shrinkage.move_lines:

                vals.update({'move_lines': [(0, 0, line_values) for line_values in shrinkage._get_move_lines_values(date_end)]})

            shrinkage.write(vals)

        

        #create stock.move.line

 

        for move in self.move_lines:

            vals = {

                'date': move.date,

                'reference': move.name,

                'product_id': move.product_id.id,

                'location_id' : move.location_id.id,

                'location_dest_id' : move.location_dest_id.id,

                'qty_done' : move.product_uom_qty,

                'move_id' : move.id,

                'product_uom_id' : move.product_uom.id,

                'to_be_secondary_qty' : move._compute_catch_weight_to_be_done(),

                'secondary_qty' : move.secondary_qty,

                }

            self.with_context({'secondary_qty': -move.secondary_qty})._create_stock_move_lines(vals)

           

        self.state = 'done'


Then when I tried to create an invoice from accounting, product1 = 2kgs , when I check availability it will return 1.99 even though I have 2kgs. Is there something wrong in my code?

Avatar
Discard
Related Posts Replies Views Activity
0
May 22
1394
0
Oct 19
3054
1
Sep 22
13538
0
Oct 24
106
3
Jan 24
2861