Skip to content

Instantly share code, notes, and snippets.

@SantosJMM
Last active January 11, 2019 21:18
Show Gist options
  • Save SantosJMM/86f02466f216ae7c35d5414d34676012 to your computer and use it in GitHub Desktop.
Save SantosJMM/86f02466f216ae7c35d5414d34676012 to your computer and use it in GitHub Desktop.
# -- coding: utf-8 --
from odoo import models, api
class StockMove(models.Model):
_inherit = 'stock.move'
def _update_qty_done(self, qty_done, product_id=None, move_line_ids=None, location_id=None, location_dest_id=None lot_id=None, package_id=None, owner_id=None, has_existence=True):
self.ensure_one()
if not product_id:
product_id = self.product_id
if not location_id:
location_id = self.location_id
if not location_dest_id:
location_dest_id = self.location_dest_id.get_putaway_strategy(product_id).id or self.location_dest_id.id
if not move_line_ids:
move_line_ids = self.move_line_ids
# Si el movimiento no tiene lineas de movimiento,
# creamos la linea de movimiento.
if not move_line_ids:
self.write({'move_line_ids':
[(0, 0,
{'qty_done': qty_done,
'product_id': product_id.id,
'location_id': location_id.id,
'location_dest_id': location_dest_id.id,
'product_uom_id': product_id.uom_id.id,
})]
})
return self.move_line_ids, self.quantity_done
self.write({'move_line_ids':
[(1, move_line_ids[0].id,
{'qty_done': qty_done}
)]
})
return self.move_line_ids, self.quantity_done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment