表面工艺外协需求,不包含页面展示外协出入库单
This commit is contained in:
@@ -230,12 +230,23 @@ class ProductionLot(models.Model):
|
||||
return "%s-%03d" % (product.name, 1)
|
||||
|
||||
|
||||
class ResStockPicking(models.Model):
|
||||
class StockPicking(models.Model):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
workorder_in_id = fields.One2many('mrp.workorder', 'picking_in_id')
|
||||
workorder_out_id = fields.One2many('mrp.workorder', 'picking_out_id')
|
||||
|
||||
# 设置外协出入单的名称
|
||||
def _get_name_Res(self, rescode):
|
||||
count = self.env['ir.sequence'].search_count([('prefix', 'like', rescode)])
|
||||
if not count:
|
||||
num = "%04d" % 1
|
||||
else:
|
||||
m = int(count) + 1
|
||||
num = "%04d" % m
|
||||
return '%s%s' % (rescode, num)
|
||||
|
||||
# 创建 外协出库入单
|
||||
def create_outcontract_picking(self, sorted_workorders_arr, item):
|
||||
m = 0
|
||||
for sorted_workorders in sorted_workorders_arr:
|
||||
@@ -247,13 +258,21 @@ class ResStockPicking(models.Model):
|
||||
'sf_manufacturing.stock_location_locations_virtual_outcontract').id,
|
||||
location_dest_id = self.env['stock.location'].search(
|
||||
[('barcode', '=', 'WH-PREPRODUCTION')]).id,
|
||||
outcontract_picking_type_in = self.env.ref(
|
||||
'sf_manufacturing.outcontract_picking_in').id,
|
||||
outcontract_picking_type_out = self.env.ref(
|
||||
'sf_manufacturing.outcontract_picking_out').id,
|
||||
moves_in = self.env['stock.move'].sudo().create(
|
||||
item._get_stock_move_values_Res(item, location_id, location_dest_id))
|
||||
item._get_stock_move_values_Res(item, location_id, location_dest_id,
|
||||
outcontract_picking_type_in))
|
||||
moves_out = self.env['stock.move'].sudo().create(
|
||||
item._get_stock_move_values_Res(item, location_dest_id, location_id))
|
||||
item._get_stock_move_values_Res(item, location_dest_id, location_id,
|
||||
outcontract_picking_type_out))
|
||||
new_picking = True
|
||||
picking_in = self.env['stock.picking'].create(moves_in._get_new_picking_values())
|
||||
picking_out = self.env['stock.picking'].create(moves_out._get_new_picking_values())
|
||||
picking_in = self.env['stock.picking'].create(
|
||||
moves_in._get_new_picking_values_Res(item, sorted_workorders,'WH/OCIN/'))
|
||||
picking_out = self.env['stock.picking'].create(
|
||||
moves_out._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCOUT/'))
|
||||
moves_in.write({'picking_id': picking_in.id})
|
||||
moves_out.write({'picking_id': picking_out.id})
|
||||
moves_in._assign_picking_post_process(new=new_picking)
|
||||
@@ -261,3 +280,20 @@ class ResStockPicking(models.Model):
|
||||
m += 1
|
||||
sorted_workorders.write({'picking_in_id': picking_in.id, 'picking_out_id': picking_out.id})
|
||||
|
||||
|
||||
class ReStockMove(models.Model):
|
||||
_inherit = 'stock.move'
|
||||
|
||||
def _get_new_picking_values_Res(self, item, sorted_workorders, rescode):
|
||||
return {
|
||||
'name': self.env['stock.picking']._get_name_Res(rescode),
|
||||
'origin': item.name,
|
||||
'company_id': self.mapped('company_id').id,
|
||||
'user_id': False,
|
||||
'move_type': self.mapped('group_id').move_type or 'direct',
|
||||
'partner_id': sorted_workorders.supplier_id.id,
|
||||
'picking_type_id': self.mapped('picking_type_id').id,
|
||||
'location_id': self.mapped('location_id').id,
|
||||
'location_dest_id': self.mapped('location_dest_id').id,
|
||||
'state': 'draft',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user