stock_picking.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- coding: utf-8 -*-
  2. from openerp import api, fields, models
  3. from openerp.exceptions import except_orm
  4. class StockPickingInsert(models.Model):
  5. _inherit = 'stock.picking'
  6. origin_location = fields.Many2one('stock.location', 'Ubicacion de Origen', compute="get_origin_location")
  7. destination_location = fields.Many2one('stock.location', 'Ubicacion de destino', domain="[('usage','<>','view')]")
  8. @api.one
  9. def get_origin_location(self):
  10. self.origin_location = self.picking_type_id.default_location_src_id.id
  11. # if self.picking_type_id.code <> 'internal':
  12. # self.destination_location = self.picking_type_id.default_location_dest_id.id
  13. @api.model
  14. def stock_insert_lines(self, values):
  15. stock_lines = self.env['stock.move']
  16. lines = stock_lines.search([
  17. ('picking_id', '=', values['id']),
  18. ('product_id', '=', values['product_id']),
  19. ])
  20. if len(lines) == 0:
  21. lines = {
  22. 'picking_id' : values['id'],
  23. 'name' : values['name'],
  24. 'product_id': values['product_id'],
  25. 'product_uom': values['product_uom'],
  26. 'location_id': values['location_id'],
  27. 'location_dest_id': values['location_dest_id'],
  28. }
  29. stock_lines.create(lines);
  30. if len(lines) == 1:
  31. lines.write({
  32. 'product_uom_qty': lines.product_uom_qty + 1,
  33. })