1234567891011121314151617181920212223242526272829303132333435363738 |
- # -*- coding: utf-8 -*-
- from openerp import api, fields, models
- from openerp.exceptions import except_orm
- class StockPickingInsert(models.Model):
- _inherit = 'stock.picking'
- origin_location = fields.Many2one('stock.location', 'Ubicacion de Origen', compute="get_origin_location")
- destination_location = fields.Many2one('stock.location', 'Ubicacion de destino', domain="[('usage','<>','view')]")
- @api.one
- def get_origin_location(self):
- self.origin_location = self.picking_type_id.default_location_src_id.id
- # if self.picking_type_id.code <> 'internal':
- # self.destination_location = self.picking_type_id.default_location_dest_id.id
- @api.model
- def stock_insert_lines(self, values):
- stock_lines = self.env['stock.move']
- lines = stock_lines.search([
- ('picking_id', '=', values['id']),
- ('product_id', '=', values['product_id']),
- ])
- if len(lines) == 0:
- lines = {
- 'picking_id' : values['id'],
- 'name' : values['name'],
- 'product_id': values['product_id'],
- 'product_uom': values['product_uom'],
- 'location_id': values['location_id'],
- 'location_dest_id': values['location_dest_id'],
- }
- stock_lines.create(lines);
- if len(lines) == 1:
- lines.write({
- 'product_uom_qty': lines.product_uom_qty + 1,
- })
|