Last active
May 7, 2022 03:01
-
-
Save altela/8c36bb91a69ec78c943258c3d1560627 to your computer and use it in GitHub Desktop.
Odoo Create Stock Move
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this block will create a stock move | |
# its recommended to put this inside a button method that checking availability | |
# ._action_confirm() will make this stock_move state to be confirmed | |
# ._action_assign() will assign this stock_move and reserve the available stock | |
stock_move = self.env['stock.move'].create({ | |
'name': 'stock_move_name', | |
'location_id': self.location_source.id, | |
'location_dest_id': self.location_destination.id, | |
'product_id': self.product.id, | |
'product_uom': self.product_uom.id, | |
'product_uom_qty': self.product_qty, | |
}) | |
stock_move._action_confirm() | |
stock_move._action_assign() | |
# this method below will create stock_move_line | |
# ._action_done() method will validate this stock_move and stock_move_line | |
# its recommended to put this inside a button method that validate the progress | |
stock_move.move_line_ids.write({'qty_done': self.product_qty}) | |
stock_move._action_done() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment