1、取消创建产品时,自动生成内部参考的值;2、优化功能刀具拆解单,修改由拆解单生成的移动历史单据编码生成规则;3、优化货位看板以及货位看板的货位变更功能;
This commit is contained in:
@@ -481,7 +481,7 @@ class ShelfLocation(models.Model):
|
||||
def action_location_status_enable(self):
|
||||
self.location_status = '空闲'
|
||||
|
||||
@api.depends('product_sn_id')
|
||||
@api.depends('product_sn_id', 'product_sn_ids')
|
||||
def _compute_product_id(self):
|
||||
"""
|
||||
根据产品序列号,获取产品
|
||||
@@ -494,7 +494,8 @@ class ShelfLocation(models.Model):
|
||||
record.sudo().product_num = 1
|
||||
except Exception as e:
|
||||
print('eeeeeee占用', e)
|
||||
|
||||
elif record.product_sn_ids:
|
||||
return True
|
||||
else:
|
||||
try:
|
||||
record.sudo().product_id = False
|
||||
@@ -543,6 +544,13 @@ class SfShelfLocationLot(models.Model):
|
||||
shelf_location_id = fields.Many2one('sf.shelf.location', string="货位")
|
||||
lot_id = fields.Many2one('stock.lot', string='批次号')
|
||||
qty = fields.Integer('数量')
|
||||
qty_num = fields.Integer('变更数量')
|
||||
|
||||
@api.onchange('qty_num')
|
||||
def _onchange_qty_num(self):
|
||||
for item in self:
|
||||
if item.qty_num > item.qty:
|
||||
raise ValidationError('变更数量不能比库存数量大!!!')
|
||||
|
||||
|
||||
class SfStockMoveLine(models.Model):
|
||||
|
||||
@@ -133,9 +133,11 @@
|
||||
type="action"
|
||||
context="{'default_name':name,
|
||||
'default_current_name':name,
|
||||
'default_current_product_sn_ids':product_sn_ids,
|
||||
'default_lot_id':product_sn_id,
|
||||
'default_current_shelf_id':shelf_id,
|
||||
'default_current_location_id':location_id,
|
||||
'default_current_barcode':barcode,
|
||||
'default_current_barcode_id':id,
|
||||
'default_current_product_id':product_id,
|
||||
}"
|
||||
class="btn-primary" attrs="{'invisible':[('location_status','!=','占用')]}"/>
|
||||
|
||||
@@ -8,17 +8,23 @@ class ShelfLocationWizard(models.TransientModel):
|
||||
|
||||
name = fields.Char('')
|
||||
|
||||
current_location_id = fields.Many2one('stock.location', string='所属库区', readonly=True)
|
||||
lot_id = fields.Many2one('stock.lot', string="序列号", readonly=True)
|
||||
|
||||
current_location_id = fields.Many2one('stock.location', string='所属库区', readonly=True)
|
||||
current_shelf_id = fields.Many2one('sf.shelf', string='当前货架', readonly=True)
|
||||
current_barcode = fields.Char('当前货位编码', readonly=True)
|
||||
current_barcode_id = fields.Many2one('sf.shelf.location', string='当前货位编码', readonly=True)
|
||||
current_name = fields.Char('当前货位名称', readonly=True)
|
||||
current_product_id = fields.Many2one('product.product', string='产品', readonly=True)
|
||||
current_product_sn_ids = fields.Many2many('sf.shelf.location.lot', 'shelf_location_wizard', string='产品批次号',
|
||||
readonly=True)
|
||||
|
||||
destination_location_id = fields.Many2one('stock.location', string='目标库区', compute='_compute_destination_name')
|
||||
destination_shelf_id = fields.Many2one('sf.shelf', string='目标货架', compute='_compute_destination_name')
|
||||
destination_barcode_id = fields.Many2one('sf.shelf.location', string='目标货位编码', required=True,
|
||||
domain="")
|
||||
domain="[('product_id', 'in', (False, current_product_id))]")
|
||||
destination_name = fields.Char('目标货位名称', compute='_compute_destination_name')
|
||||
destination_product_sn_ids = fields.Many2many('sf.shelf.location.lot', 'shelf_location_wizard', string='批次号',
|
||||
domain="[('shelf_location_id', '=', current_barcode_id)]")
|
||||
|
||||
def return_domain(self):
|
||||
val = [('location_status', '=', '空闲')]
|
||||
@@ -32,9 +38,11 @@ class ShelfLocationWizard(models.TransientModel):
|
||||
def _compute_destination_name(self):
|
||||
if self.destination_barcode_id:
|
||||
self.destination_name = self.destination_barcode_id.name
|
||||
self.destination_location_id = self.destination_barcode_id.location_id.id
|
||||
self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
|
||||
else:
|
||||
self.destination_name = ''
|
||||
self.destination_location_id = False
|
||||
self.destination_shelf_id = False
|
||||
|
||||
#
|
||||
@@ -43,22 +51,46 @@ class ShelfLocationWizard(models.TransientModel):
|
||||
# if self.destination_barcode_id:
|
||||
# self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
|
||||
|
||||
def confirm_the_change(self):
|
||||
shelf_location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.current_barcode)])
|
||||
# 变更货位
|
||||
if self.destination_barcode_id and shelf_location:
|
||||
if self.destination_barcode_id.product_id and self.destination_barcode_id.product_id == shelf_location.product_id and not self.destination_barcode_id.product_sn_id:
|
||||
self.destination_barcode_id.product_num += shelf_location.product_num
|
||||
else:
|
||||
self.destination_barcode_id.product_sn_id = shelf_location.product_sn_id.id
|
||||
self.destination_barcode_id.product_id = shelf_location.product_id.id
|
||||
self.destination_barcode_id.product_num = shelf_location.product_num
|
||||
def create_stock_moves(self, lot_id, num):
|
||||
# 创建产品货位变更的库存移动记录
|
||||
stock_move_id = self.env['stock.move'].sudo().create({
|
||||
'name': 'HWBG/%s' % self.id,
|
||||
'product_id': self.current_product_id.id,
|
||||
'location_id': self.current_location_id.id,
|
||||
'location_dest_id': self.destination_location_id.id,
|
||||
'product_uom_qty': num,
|
||||
'state': 'done'
|
||||
})
|
||||
# 创建移动历史记录
|
||||
stock_move_line_id = self.env['stock.move.line'].sudo().create({
|
||||
'product_id': self.current_product_id.id,
|
||||
'lot_id': lot_id.id,
|
||||
'move_id': stock_move_id.id,
|
||||
'current_location_id': self.current_barcode_id.id,
|
||||
'destination_location_id': self.destination_barcode_id.id,
|
||||
'install_tool_time': fields.Datetime.now(),
|
||||
'qty_done': num,
|
||||
'state': 'done'
|
||||
})
|
||||
|
||||
shelf_location.product_sn_id = False
|
||||
shelf_location.product_id = False
|
||||
shelf_location.product_num = 0
|
||||
return stock_move_id, stock_move_line_id
|
||||
|
||||
def confirm_the_change(self):
|
||||
if self.destination_barcode_id:
|
||||
if self.lot_id:
|
||||
self.current_barcode_id.product_sn_id = False
|
||||
self.destination_barcode_id.product_sn_id = self.lot_id.id
|
||||
self.create_stock_moves(self.lot_id, 1)
|
||||
elif self.current_product_sn_ids:
|
||||
for current_product_sn_id in self.current_product_sn_ids:
|
||||
self.create_stock_moves(current_product_sn_id.lot_id, current_product_sn_id.qty_num)
|
||||
current_product_sn_id.write({
|
||||
'qty_num': 0
|
||||
})
|
||||
else:
|
||||
raise ValidationError('没有需要变更的批次/序列号!')
|
||||
else:
|
||||
raise ValidationError('目标货位出错,请联系管理员!')
|
||||
raise ValidationError('请选择目标货位编码!')
|
||||
|
||||
# 关闭弹出窗口
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
@@ -6,27 +6,45 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="货位变更">
|
||||
<sheet>
|
||||
<group>
|
||||
<group col="1">
|
||||
<group string="初始货位">
|
||||
<group>
|
||||
<field name="current_location_id"/>
|
||||
<field name="current_shelf_id" string="货架"/>
|
||||
<field name="current_barcode" string="编码"/>
|
||||
<field name="current_name" string="名称"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="current_barcode_id" string="编码"/>
|
||||
<field name="lot_id" attrs="{'invisible': [('lot_id', '=', False)]}"/>
|
||||
</group>
|
||||
<field name="current_product_sn_ids"
|
||||
attrs="{'invisible': [('current_product_sn_ids', '=', [])]}">
|
||||
<tree edit="1" create="0" delete="0" editable="bottom">
|
||||
<field name="lot_id" readonly="1"/>
|
||||
<field name="qty" readonly="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<group string="目标货位">
|
||||
<group>
|
||||
<field name="current_location_id"/>
|
||||
<field name="destination_shelf_id" string="货架" options="{'no_create': True}"
|
||||
placeholder="请选择目标货架"/>
|
||||
<field name="destination_barcode_id" string="编码" options="{'no_create': True}"
|
||||
placeholder="请选择目标货位"
|
||||
domain="['|', ('location_status', '=', '空闲'), ('product_id', '=', current_product_id)]"/>
|
||||
<field name="destination_location_id"/>
|
||||
<field name="destination_shelf_id" string="货架" options="{'no_create': True}"/>
|
||||
<field name="destination_name" string="名称"/>
|
||||
<field name="current_product_id" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="destination_barcode_id" string="编码" options="{'no_create': True}"
|
||||
placeholder="请选择目标货位"/>
|
||||
<field name="lot_id" attrs="{'invisible': [('lot_id', '=', False)]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<field name="destination_product_sn_ids"
|
||||
attrs="{'invisible': [('current_product_sn_ids', '=', [])]}">
|
||||
<tree edit="1" create="0" delete="1" editable="bottom">
|
||||
<field name="lot_id" readonly="1"/>
|
||||
<field name="qty_num"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
</sheet>
|
||||
<footer>
|
||||
|
||||
Reference in New Issue
Block a user