Merge branch 'feature/调拨单优化' into feature/调拨单优化1
This commit is contained in:
@@ -557,8 +557,10 @@ class SfStockMoveLine(models.Model):
|
||||
_name = 'stock.move.line'
|
||||
_inherit = ['stock.move.line', 'printing.utils']
|
||||
|
||||
stock_lot_name = fields.Char('序列号名称', related='lot_id.name')
|
||||
current_location_id = fields.Many2one(
|
||||
'sf.shelf.location', string='当前货位', compute='_compute_current_location_id', store=True)
|
||||
'sf.shelf.location', string='当前货位', compute='_compute_current_location_id', store=True, readonly=False,
|
||||
domain="[('product_id', '=', product_id),'|',('product_sn_id.name', '=', stock_lot_name),('product_sn_ids.lot_id.name','=',stock_lot_name)]")
|
||||
# location_dest_id = fields.Many2one('stock.location', string='目标库位')
|
||||
location_dest_id_product_type = fields.Many2many(related='location_dest_id.product_type')
|
||||
location_dest_id_value = fields.Integer(compute='_compute_location_dest_id_value', store=True)
|
||||
@@ -856,7 +858,9 @@ class SfStockMoveLine(models.Model):
|
||||
def compute_destination_location_id(self):
|
||||
for record in self:
|
||||
obj = self.env['sf.shelf.location'].search([('name', '=',
|
||||
self.destination_location_id.name)])
|
||||
record.destination_location_id.name)])
|
||||
if obj and obj.product_id and obj.product_id != record.product_id:
|
||||
raise ValidationError('目标货位【%s】已被【%s】产品占用!' % (obj.code, obj.product_id))
|
||||
if record.lot_id:
|
||||
if record.product_id.tracking == 'serial':
|
||||
shelf_location_obj = self.env['sf.shelf.location'].search(
|
||||
@@ -869,7 +873,7 @@ class SfStockMoveLine(models.Model):
|
||||
if obj:
|
||||
obj.product_sn_id = record.lot_id.id
|
||||
elif record.product_id.tracking == 'lot':
|
||||
self.put_shelf_location(record)
|
||||
record.put_shelf_location(record)
|
||||
if not obj.product_id:
|
||||
obj.product_id = record.product_id.id
|
||||
else:
|
||||
@@ -980,15 +984,26 @@ class SfStockPicking(models.Model):
|
||||
# 调用入库方法进行入库刀货位
|
||||
line.compute_destination_location_id()
|
||||
else:
|
||||
# 对除刀柄之外的刀具物料进行 目标货位必填校验
|
||||
# 对除刀柄之外的刀具物料入库到刀具房进行 目标货位必填校验
|
||||
if self.location_dest_id.name == '刀具房' and line.product_id.cutting_tool_material_id.name not in (
|
||||
'刀柄', False):
|
||||
raise ValidationError('请选择【%s】产品的目标货位!' % line.product_id.name)
|
||||
if line.current_location_id:
|
||||
# 对货位的批次产品进行出货
|
||||
line.put_shelf_location(line)
|
||||
|
||||
if line.current_location_id:
|
||||
# 按序列号管理的产品
|
||||
if line.current_location_id.product_sn_id:
|
||||
line.current_location_id.product_sn_id = False
|
||||
# line.current_location_id.location_status = '空闲'
|
||||
line.current_location_id.product_num = 0
|
||||
line.current_location_id.product_id = False
|
||||
else:
|
||||
# 对除刀柄之外的刀具物料从刀具房出库进行 当前货位必填校验
|
||||
if self.location_id.name == '刀具房' and line.product_id.cutting_tool_material_id.name not in (
|
||||
'刀柄', False):
|
||||
raise ValidationError('请选择【%s】产品的当前货位!' % line.product_id.name)
|
||||
|
||||
# 对入库作业的刀柄和托盘进行Rfid绑定校验
|
||||
for move in self.move_ids:
|
||||
@@ -1115,6 +1130,7 @@ class CustomStockMove(models.Model):
|
||||
采购入库扫码绑定Rfid码
|
||||
"""
|
||||
for record in self:
|
||||
logging.info('Rfid:%s' % barcode)
|
||||
if record:
|
||||
lot = self.env['stock.lot'].sudo().search([('rfid', '=', barcode)])
|
||||
if lot:
|
||||
@@ -1126,7 +1142,9 @@ class CustomStockMove(models.Model):
|
||||
'该Rfid【%s】已经被序列号为【%s】的【%s】物料所占用!' % (barcode, lot.name, material))
|
||||
if '刀柄' in (record.product_id.cutting_tool_material_id.name or '') or '托盘' in (
|
||||
record.product_id.fixture_material_id.name or ''):
|
||||
logging.info('开始录入Rfid:%s' % record.move_line_nosuggest_ids)
|
||||
for move_line_nosuggest_id in record.move_line_nosuggest_ids:
|
||||
logging.info('录入的记录%s , Rfid:%s' % (move_line_nosuggest_id, move_line_nosuggest_id.rfid))
|
||||
if move_line_nosuggest_id.rfid:
|
||||
if move_line_nosuggest_id.rfid == barcode:
|
||||
if record.product_id.cutting_tool_material_id.name:
|
||||
@@ -1135,7 +1153,9 @@ class CustomStockMove(models.Model):
|
||||
raise ValidationError('该托盘的Rfid已经录入,请勿重复录入!!!')
|
||||
else:
|
||||
line_id = int(re.sub(r"\D", "", str(move_line_nosuggest_id.id)))
|
||||
self.env['stock.move.line'].sudo().search([('id', '=', line_id)]).write({'rfid': barcode})
|
||||
res = self.env['stock.move.line'].sudo().search([('id', '=', line_id)]).write(
|
||||
{'rfid': barcode})
|
||||
logging.info('Rfid是否录入:%s' % res)
|
||||
move_line_nosuggest_id.rfid = barcode
|
||||
break
|
||||
else:
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
<field name="inherit_id" ref="stock.view_stock_move_line_detailed_operation_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='location_id'][2]" position="after">
|
||||
<field name="current_location_id" force_save="1"/>
|
||||
<field name="stock_lot_name" invisible="1"/>
|
||||
<field name="current_location_id" force_save="1"
|
||||
options="{'no_create': True,'no_create_edit':True}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='location_dest_id'][2]" position="after">
|
||||
<field name="current_product_id" invisible="1"/>
|
||||
@@ -55,6 +57,7 @@
|
||||
<field name="inherit_id" ref="stock.view_move_line_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form//sheet//group//group//field[@name='location_id']" position="after">
|
||||
<field name="stock_lot_name" invisible="1"/>
|
||||
<field name="current_location_id" options="{'no_create': False}" force_save="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//form//sheet//group//group//field[@name='location_dest_id']" position="after">
|
||||
|
||||
Reference in New Issue
Block a user