1、优化客供料入库单的追溯参考字段自动计算方法
This commit is contained in:
@@ -131,9 +131,9 @@ class StockRule(models.Model):
|
|||||||
if num > 1:
|
if num > 1:
|
||||||
for no in range(1, num + 1):
|
for no in range(1, num + 1):
|
||||||
Procurement = namedtuple('Procurement', ['product_id', 'product_qty',
|
Procurement = namedtuple('Procurement', ['product_id', 'product_qty',
|
||||||
'product_uom', 'location_id', 'name', 'origin',
|
'product_uom', 'location_id', 'name', 'origin',
|
||||||
'company_id',
|
'company_id',
|
||||||
'values'])
|
'values'])
|
||||||
s = Procurement(product_id=item[0].product_id, product_qty=1.0, product_uom=item[0].product_uom,
|
s = Procurement(product_id=item[0].product_id, product_qty=1.0, product_uom=item[0].product_uom,
|
||||||
location_id=item[0].location_id,
|
location_id=item[0].location_id,
|
||||||
name=item[0].name,
|
name=item[0].name,
|
||||||
@@ -324,12 +324,15 @@ class StockRule(models.Model):
|
|||||||
for k in (production_item.product_id.model_processing_panel.split(',')):
|
for k in (production_item.product_id.model_processing_panel.split(',')):
|
||||||
if production_item.production_type == '自动化产线加工':
|
if production_item.production_type == '自动化产线加工':
|
||||||
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
|
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
|
||||||
[('product_model_type_id', '=', production_item.product_id.product_model_type_id.id)],
|
[('product_model_type_id', '=',
|
||||||
|
production_item.product_id.product_model_type_id.id)],
|
||||||
order='sequence asc'
|
order='sequence asc'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
product_routing_workcenter = self.env['sf.manual.product.model.type.routing.sort'].search(
|
product_routing_workcenter = self.env[
|
||||||
[('manual_product_model_type_id', '=', production_item.product_id.product_model_type_id.id)],
|
'sf.manual.product.model.type.routing.sort'].search(
|
||||||
|
[('manual_product_model_type_id', '=',
|
||||||
|
production_item.product_id.product_model_type_id.id)],
|
||||||
order='sequence asc'
|
order='sequence asc'
|
||||||
)
|
)
|
||||||
for route in product_routing_workcenter:
|
for route in product_routing_workcenter:
|
||||||
@@ -592,18 +595,18 @@ class StockPicking(models.Model):
|
|||||||
for move_id in item.move_ids:
|
for move_id in item.move_ids:
|
||||||
move_ids.append(move_id.product_id.id)
|
move_ids.append(move_id.product_id.id)
|
||||||
boms = self.env['mrp.bom'].sudo().search([('bom_line_ids.product_id', 'in', move_ids)])
|
boms = self.env['mrp.bom'].sudo().search([('bom_line_ids.product_id', 'in', move_ids)])
|
||||||
default_codes = ''
|
|
||||||
if boms:
|
if boms:
|
||||||
|
codes_list = []
|
||||||
for bom in boms:
|
for bom in boms:
|
||||||
if bom.product_tmpl_id.default_code:
|
if bom.product_tmpl_id.default_code:
|
||||||
code = bom.product_tmpl_id.default_code.split('-')[-1]
|
code_list = bom.product_tmpl_id.default_code.split('-')
|
||||||
default_code = bom.product_tmpl_id.default_code.split(f'-{code}')[0]
|
if len(code_list) >= 4:
|
||||||
if default_code not in default_codes:
|
code = '-'.join(code_list[:4])
|
||||||
if default_codes == '':
|
if code not in codes_list:
|
||||||
default_codes = default_code
|
codes_list.append(code)
|
||||||
else:
|
else:
|
||||||
default_codes = default_codes + ',' + default_code
|
raise ValidationError('坯料成品的内部参考值格式错误')
|
||||||
item.retrospect_ref = default_codes
|
item.retrospect_ref = ','.join(codes_list)
|
||||||
elif item.picking_type_id.sequence_code in ['INT', 'PC']:
|
elif item.picking_type_id.sequence_code in ['INT', 'PC']:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -946,7 +949,7 @@ class ReStockMove(models.Model):
|
|||||||
move_lines_commands.append((0, 0, move_line_cmd))
|
move_lines_commands.append((0, 0, move_line_cmd))
|
||||||
qty_by_location[loc.id] += 1
|
qty_by_location[loc.id] += 1
|
||||||
return move_lines_commands
|
return move_lines_commands
|
||||||
|
|
||||||
def _merge_moves_fields(self):
|
def _merge_moves_fields(self):
|
||||||
"""
|
"""
|
||||||
合并制造订单的完成move单据
|
合并制造订单的完成move单据
|
||||||
@@ -954,19 +957,20 @@ class ReStockMove(models.Model):
|
|||||||
res = super(ReStockMove, self)._merge_moves_fields()
|
res = super(ReStockMove, self)._merge_moves_fields()
|
||||||
res = self._single_manufactuing_mo_generate_origin(res)
|
res = self._single_manufactuing_mo_generate_origin(res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_new_picking_values(self):
|
def _get_new_picking_values(self):
|
||||||
res = super(ReStockMove, self)._get_new_picking_values()
|
res = super(ReStockMove, self)._get_new_picking_values()
|
||||||
res = self._single_manufactuing_mo_generate_origin(res)
|
res = self._single_manufactuing_mo_generate_origin(res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _single_manufactuing_mo_generate_origin(self, res):
|
def _single_manufactuing_mo_generate_origin(self, res):
|
||||||
"""
|
"""
|
||||||
单个制造订单的完成move单据修改来源为该制造订单关联的销售订单下所有成品相同的制造订单
|
单个制造订单的完成move单据修改来源为该制造订单关联的销售订单下所有成品相同的制造订单
|
||||||
"""
|
"""
|
||||||
if self[0].origin and self.picking_type_id.name in ['生产发料', '内部调拨']:
|
if self[0].origin and self.picking_type_id.name in ['生产发料', '内部调拨']:
|
||||||
production = self.env['mrp.production'].search([('name', '=', self[0].origin)], limit=1, order='id asc')
|
production = self.env['mrp.production'].search([('name', '=', self[0].origin)], limit=1, order='id asc')
|
||||||
productions = self.env['mrp.production'].search([('origin', '=', production.origin), ('product_id', '=', production.product_id.id)])
|
productions = self.env['mrp.production'].search(
|
||||||
|
[('origin', '=', production.origin), ('product_id', '=', production.product_id.id)])
|
||||||
res['origin'] = ','.join(productions.mapped('name'))
|
res['origin'] = ','.join(productions.mapped('name'))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user