1、取消创建产品时,自动生成内部参考的值;2、优化功能刀具拆解单,修改由拆解单生成的移动历史单据编码生成规则;3、优化货位看板以及货位看板的货位变更功能;
This commit is contained in:
@@ -102,11 +102,11 @@
|
|||||||
'刀具')], 'required': True}
|
'刀具')], 'required': True}
|
||||||
</attribute>
|
</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='default_code']" position="attributes">
|
<!-- <xpath expr="//field[@name='default_code']" position="attributes">-->
|
||||||
<attribute name="attrs">{'readonly': [('categ_type', '=', '刀具')], 'invisible':
|
<!-- <attribute name="attrs">{'readonly': [('categ_type', '=', '刀具')], 'invisible':-->
|
||||||
[('product_variant_count', '>' , 1)]}
|
<!-- [('product_variant_count', '>' , 1)]}-->
|
||||||
</attribute>
|
<!-- </attribute>-->
|
||||||
</xpath>
|
<!-- </xpath>-->
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
@@ -106,17 +106,12 @@ class ResProductMo(models.Model):
|
|||||||
|
|
||||||
name = fields.Char('产品名称', compute='_compute_tool_name', store=True, required=False)
|
name = fields.Char('产品名称', compute='_compute_tool_name', store=True, required=False)
|
||||||
|
|
||||||
@api.depends('categ_id', 'cutting_tool_material_id', 'cutting_tool_model_id', 'specification_id')
|
@api.depends('cutting_tool_model_id', 'specification_id')
|
||||||
def _compute_tool_name(self):
|
def _compute_tool_name(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
if item.cutting_tool_model_id and item.specification_id:
|
if item.cutting_tool_model_id and item.specification_id:
|
||||||
name = '%s%s' % (item.cutting_tool_model_id.name, item.specification_id.name)
|
name = '%s%s' % (item.cutting_tool_model_id.name, item.specification_id.name)
|
||||||
item.name = name
|
item.name = name
|
||||||
if item.categ_id and item.cutting_tool_material_id and item.cutting_tool_model_id:
|
|
||||||
if item.cutting_tool_model_id.code:
|
|
||||||
default_code = '%s-T-DJWL-%s' % (
|
|
||||||
item.cutting_tool_model_id.code.split('-')[0], item.cutting_tool_material_id.code)
|
|
||||||
item.default_code = default_code
|
|
||||||
|
|
||||||
@api.onchange('cutting_tool_model_id')
|
@api.onchange('cutting_tool_model_id')
|
||||||
def _onchange_cutting_tool_model_id(self):
|
def _onchange_cutting_tool_model_id(self):
|
||||||
|
|||||||
@@ -824,6 +824,7 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
|
|
||||||
def confirmation_disassembly(self):
|
def confirmation_disassembly(self):
|
||||||
logging.info('%s刀具确认开始拆解' % self.dismantle_cause)
|
logging.info('%s刀具确认开始拆解' % self.dismantle_cause)
|
||||||
|
t_id = self.id
|
||||||
if self.functional_tool_id.functional_tool_status == '已拆除':
|
if self.functional_tool_id.functional_tool_status == '已拆除':
|
||||||
raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle)
|
raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle)
|
||||||
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
||||||
@@ -848,15 +849,19 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
# 除刀柄外物料报废 入库到Scrap
|
# 除刀柄外物料报废 入库到Scrap
|
||||||
if self.integral_product_id:
|
if self.integral_product_id:
|
||||||
self.integral_product_id.dismantle_stock_moves(False, self.integral_lot_id, location,
|
self.integral_product_id.dismantle_stock_moves(False, self.integral_lot_id, location,
|
||||||
location_dest_scrap)
|
location_dest_scrap, t_id)
|
||||||
elif self.blade_product_id:
|
elif self.blade_product_id:
|
||||||
self.blade_product_id.dismantle_stock_moves(False, self.blade_lot_id, location, location_dest_scrap)
|
self.blade_product_id.dismantle_stock_moves(False, self.blade_lot_id, location, location_dest_scrap,
|
||||||
|
t_id)
|
||||||
if self.bar_product_id:
|
if self.bar_product_id:
|
||||||
self.bar_product_id.dismantle_stock_moves(False, self.bar_lot_id, location, location_dest_scrap)
|
self.bar_product_id.dismantle_stock_moves(False, self.bar_lot_id, location, location_dest_scrap,
|
||||||
|
t_id)
|
||||||
elif self.pad_product_id:
|
elif self.pad_product_id:
|
||||||
self.pad_product_id.dismantle_stock_moves(False, self.pad_lot_id, location, location_dest_scrap)
|
self.pad_product_id.dismantle_stock_moves(False, self.pad_lot_id, location, location_dest_scrap,
|
||||||
|
t_id)
|
||||||
if self.chuck_product_id:
|
if self.chuck_product_id:
|
||||||
self.chuck_product_id.dismantle_stock_moves(False, self.chuck_lot_id, location, location_dest_scrap)
|
self.chuck_product_id.dismantle_stock_moves(False, self.chuck_lot_id, location, location_dest_scrap,
|
||||||
|
t_id)
|
||||||
# ===========功能刀具[磨削]拆解==============
|
# ===========功能刀具[磨削]拆解==============
|
||||||
# elif self.dismantle_cause in ['刀具需磨削']:
|
# elif self.dismantle_cause in ['刀具需磨削']:
|
||||||
# location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
|
# location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
|
||||||
@@ -876,19 +881,19 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
# 除刀柄外物料拆解 入库到具体货位
|
# 除刀柄外物料拆解 入库到具体货位
|
||||||
if self.integral_freight_id:
|
if self.integral_freight_id:
|
||||||
self.integral_product_id.dismantle_stock_moves(self.integral_freight_id, self.integral_lot_id, location,
|
self.integral_product_id.dismantle_stock_moves(self.integral_freight_id, self.integral_lot_id, location,
|
||||||
location_dest)
|
location_dest, t_id)
|
||||||
elif self.blade_freight_id:
|
elif self.blade_freight_id:
|
||||||
self.blade_product_id.dismantle_stock_moves(self.blade_freight_id, self.blade_lot_id, location,
|
self.blade_product_id.dismantle_stock_moves(self.blade_freight_id, self.blade_lot_id, location,
|
||||||
location_dest)
|
location_dest, t_id)
|
||||||
if self.bar_freight_id:
|
if self.bar_freight_id:
|
||||||
self.bar_product_id.dismantle_stock_moves(self.bar_freight_id, self.bar_lot_id, location,
|
self.bar_product_id.dismantle_stock_moves(self.bar_freight_id, self.bar_lot_id, location,
|
||||||
location_dest)
|
location_dest, t_id)
|
||||||
elif self.pad_freight_id:
|
elif self.pad_freight_id:
|
||||||
self.pad_product_id.dismantle_stock_moves(self.pad_freight_id, self.pad_lot_id, location,
|
self.pad_product_id.dismantle_stock_moves(self.pad_freight_id, self.pad_lot_id, location,
|
||||||
location_dest)
|
location_dest, t_id)
|
||||||
if self.chuck_freight_id:
|
if self.chuck_freight_id:
|
||||||
self.chuck_product_id.dismantle_stock_moves(self.chuck_freight_id, self.chuck_lot_id, location,
|
self.chuck_product_id.dismantle_stock_moves(self.chuck_freight_id, self.chuck_lot_id, location,
|
||||||
location_dest)
|
location_dest, t_id)
|
||||||
# ===============删除功能刀具的Rfid字段的值, 赋值给Rfid(已拆解)字段=====
|
# ===============删除功能刀具的Rfid字段的值, 赋值给Rfid(已拆解)字段=====
|
||||||
self.functional_tool_id.write({
|
self.functional_tool_id.write({
|
||||||
'rfid_dismantle': self.functional_tool_id.rfid,
|
'rfid_dismantle': self.functional_tool_id.rfid,
|
||||||
@@ -909,10 +914,10 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
class ProductProduct(models.Model):
|
class ProductProduct(models.Model):
|
||||||
_inherit = 'product.product'
|
_inherit = 'product.product'
|
||||||
|
|
||||||
def dismantle_stock_moves(self, shelf_location_id, lot_id, location_id, location_dest_id):
|
def dismantle_stock_moves(self, shelf_location_id, lot_id, location_id, location_dest_id, t_id):
|
||||||
# 创建功能刀具拆解单产品库存移动记录
|
# 创建功能刀具拆解单产品库存移动记录
|
||||||
stock_move_id = self.env['stock.move'].sudo().create({
|
stock_move_id = self.env['stock.move'].sudo().create({
|
||||||
'name': '功能刀具拆解',
|
'name': 'DJCJ/%s' % t_id,
|
||||||
'product_id': self.id,
|
'product_id': self.id,
|
||||||
'location_id': location_id.id,
|
'location_id': location_id.id,
|
||||||
'location_dest_id': location_dest_id.id,
|
'location_dest_id': location_dest_id.id,
|
||||||
|
|||||||
@@ -481,7 +481,7 @@ class ShelfLocation(models.Model):
|
|||||||
def action_location_status_enable(self):
|
def action_location_status_enable(self):
|
||||||
self.location_status = '空闲'
|
self.location_status = '空闲'
|
||||||
|
|
||||||
@api.depends('product_sn_id')
|
@api.depends('product_sn_id', 'product_sn_ids')
|
||||||
def _compute_product_id(self):
|
def _compute_product_id(self):
|
||||||
"""
|
"""
|
||||||
根据产品序列号,获取产品
|
根据产品序列号,获取产品
|
||||||
@@ -494,7 +494,8 @@ class ShelfLocation(models.Model):
|
|||||||
record.sudo().product_num = 1
|
record.sudo().product_num = 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('eeeeeee占用', e)
|
print('eeeeeee占用', e)
|
||||||
|
elif record.product_sn_ids:
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
record.sudo().product_id = False
|
record.sudo().product_id = False
|
||||||
@@ -543,6 +544,13 @@ class SfShelfLocationLot(models.Model):
|
|||||||
shelf_location_id = fields.Many2one('sf.shelf.location', string="货位")
|
shelf_location_id = fields.Many2one('sf.shelf.location', string="货位")
|
||||||
lot_id = fields.Many2one('stock.lot', string='批次号')
|
lot_id = fields.Many2one('stock.lot', string='批次号')
|
||||||
qty = fields.Integer('数量')
|
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):
|
class SfStockMoveLine(models.Model):
|
||||||
|
|||||||
@@ -133,9 +133,11 @@
|
|||||||
type="action"
|
type="action"
|
||||||
context="{'default_name':name,
|
context="{'default_name':name,
|
||||||
'default_current_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_shelf_id':shelf_id,
|
||||||
'default_current_location_id':location_id,
|
'default_current_location_id':location_id,
|
||||||
'default_current_barcode':barcode,
|
'default_current_barcode_id':id,
|
||||||
'default_current_product_id':product_id,
|
'default_current_product_id':product_id,
|
||||||
}"
|
}"
|
||||||
class="btn-primary" attrs="{'invisible':[('location_status','!=','占用')]}"/>
|
class="btn-primary" attrs="{'invisible':[('location_status','!=','占用')]}"/>
|
||||||
|
|||||||
@@ -8,17 +8,23 @@ class ShelfLocationWizard(models.TransientModel):
|
|||||||
|
|
||||||
name = fields.Char('')
|
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_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_name = fields.Char('当前货位名称', readonly=True)
|
||||||
current_product_id = fields.Many2one('product.product', string='产品', 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_shelf_id = fields.Many2one('sf.shelf', string='目标货架', compute='_compute_destination_name')
|
||||||
destination_barcode_id = fields.Many2one('sf.shelf.location', string='目标货位编码', required=True,
|
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_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):
|
def return_domain(self):
|
||||||
val = [('location_status', '=', '空闲')]
|
val = [('location_status', '=', '空闲')]
|
||||||
@@ -32,9 +38,11 @@ class ShelfLocationWizard(models.TransientModel):
|
|||||||
def _compute_destination_name(self):
|
def _compute_destination_name(self):
|
||||||
if self.destination_barcode_id:
|
if self.destination_barcode_id:
|
||||||
self.destination_name = self.destination_barcode_id.name
|
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
|
self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
|
||||||
else:
|
else:
|
||||||
self.destination_name = ''
|
self.destination_name = ''
|
||||||
|
self.destination_location_id = False
|
||||||
self.destination_shelf_id = False
|
self.destination_shelf_id = False
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -43,22 +51,46 @@ class ShelfLocationWizard(models.TransientModel):
|
|||||||
# if self.destination_barcode_id:
|
# if self.destination_barcode_id:
|
||||||
# self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
|
# self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
|
||||||
|
|
||||||
def confirm_the_change(self):
|
def create_stock_moves(self, lot_id, num):
|
||||||
shelf_location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.current_barcode)])
|
# 创建产品货位变更的库存移动记录
|
||||||
# 变更货位
|
stock_move_id = self.env['stock.move'].sudo().create({
|
||||||
if self.destination_barcode_id and shelf_location:
|
'name': 'HWBG/%s' % self.id,
|
||||||
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:
|
'product_id': self.current_product_id.id,
|
||||||
self.destination_barcode_id.product_num += shelf_location.product_num
|
'location_id': self.current_location_id.id,
|
||||||
else:
|
'location_dest_id': self.destination_location_id.id,
|
||||||
self.destination_barcode_id.product_sn_id = shelf_location.product_sn_id.id
|
'product_uom_qty': num,
|
||||||
self.destination_barcode_id.product_id = shelf_location.product_id.id
|
'state': 'done'
|
||||||
self.destination_barcode_id.product_num = shelf_location.product_num
|
})
|
||||||
|
# 创建移动历史记录
|
||||||
|
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
|
return stock_move_id, stock_move_line_id
|
||||||
shelf_location.product_id = False
|
|
||||||
shelf_location.product_num = 0
|
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:
|
else:
|
||||||
raise ValidationError('目标货位出错,请联系管理员!')
|
raise ValidationError('没有需要变更的批次/序列号!')
|
||||||
|
else:
|
||||||
|
raise ValidationError('请选择目标货位编码!')
|
||||||
|
|
||||||
# 关闭弹出窗口
|
# 关闭弹出窗口
|
||||||
return {'type': 'ir.actions.act_window_close'}
|
return {'type': 'ir.actions.act_window_close'}
|
||||||
|
|||||||
@@ -6,28 +6,46 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="货位变更">
|
<form string="货位变更">
|
||||||
<sheet>
|
<sheet>
|
||||||
<group>
|
<group col="1">
|
||||||
<group string="初始货位">
|
<group string="初始货位">
|
||||||
<group>
|
<group>
|
||||||
<field name="current_location_id"/>
|
<field name="current_location_id"/>
|
||||||
<field name="current_shelf_id" string="货架"/>
|
<field name="current_shelf_id" string="货架"/>
|
||||||
<field name="current_barcode" string="编码"/>
|
|
||||||
<field name="current_name" string="名称"/>
|
<field name="current_name" string="名称"/>
|
||||||
</group>
|
</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>
|
||||||
<group string="目标货位">
|
<group string="目标货位">
|
||||||
<group>
|
<group>
|
||||||
<field name="current_location_id"/>
|
<field name="destination_location_id"/>
|
||||||
<field name="destination_shelf_id" string="货架" options="{'no_create': True}"
|
<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_name" string="名称"/>
|
<field name="destination_name" string="名称"/>
|
||||||
<field name="current_product_id" invisible="1"/>
|
<field name="current_product_id" invisible="1"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="destination_barcode_id" string="编码" options="{'no_create': True}"
|
||||||
|
placeholder="请选择目标货位"/>
|
||||||
|
<field name="lot_id" attrs="{'invisible': [('lot_id', '=', False)]}"/>
|
||||||
</group>
|
</group>
|
||||||
</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>
|
</sheet>
|
||||||
<footer>
|
<footer>
|
||||||
<button string="确定" name="confirm_the_change" type="object" class="btn-primary"
|
<button string="确定" name="confirm_the_change" type="object" class="btn-primary"
|
||||||
|
|||||||
Reference in New Issue
Block a user