Accept Merge Request #1072: (release/release_1.5 -> develop)
Merge Request: 添加刀具按批次管理 Created By: @禹翔辉 Reviewed By: @马广威 Approved By: @马广威 Accepted By: @马广威 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1072
This commit is contained in:
@@ -126,4 +126,4 @@ class Manufacturing_Connect(http.Controller):
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
logging.info('put_tool_preset_parameter_port error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@@ -181,6 +181,7 @@ class MachineTableToolChangingApply(models.Model):
|
||||
|
||||
class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||
_name = 'sf.cam.work.order.program.knife.plan'
|
||||
_inherit = ['mail.thread']
|
||||
_description = 'CAM工单程序用刀计划'
|
||||
|
||||
name = fields.Char('工单任务编号')
|
||||
@@ -228,7 +229,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||
estimated_processing_time = fields.Char('预计加工时间')
|
||||
|
||||
plan_execute_status = fields.Selection([('0', '待下发'), ('1', '执行中'), ('2', '已完成')],
|
||||
string='计划执行状态', default='0', readonly=False)
|
||||
string='计划执行状态', default='0', readonly=False, tracking=True)
|
||||
|
||||
sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True)
|
||||
|
||||
@@ -362,6 +363,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||
|
||||
class FunctionalToolAssembly(models.Model):
|
||||
_name = 'sf.functional.tool.assembly'
|
||||
_inherit = ['mail.thread']
|
||||
_description = '功能刀具组装'
|
||||
_order = 'assemble_status, use_tool_time asc'
|
||||
|
||||
@@ -396,7 +398,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
applicant = fields.Char(string='申请人', readonly=True)
|
||||
apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now(), readonly=True)
|
||||
assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装')], string='组装状态', default='0',
|
||||
readonly=True)
|
||||
tracking=True, readonly=True)
|
||||
cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True)
|
||||
whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=True)
|
||||
reason_for_applying = fields.Char(string='申请原因', readonly=True)
|
||||
@@ -413,8 +415,9 @@ class FunctionalToolAssembly(models.Model):
|
||||
return categories.browse(functional_tool_type_ids)
|
||||
|
||||
# 刀具物料信息
|
||||
# ==============整体式刀具型号============
|
||||
integral_freight_barcode = fields.Char('整体式刀具货位')
|
||||
# ==============整体式刀具型号=============
|
||||
integral_freight_barcode_id = fields.Many2one('sf.shelf.location', string='整体式刀具货位')
|
||||
integral_lot_id = fields.Many2one('stock.lot', string='整体式刀具批次')
|
||||
integral_product_id = fields.Many2one('product.product', string='整体式刀具名称',
|
||||
compute='_compute_integral_product_id', store=True)
|
||||
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
|
||||
@@ -424,19 +427,15 @@ class FunctionalToolAssembly(models.Model):
|
||||
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
|
||||
related='integral_product_id.brand_id')
|
||||
|
||||
@api.depends('integral_freight_barcode')
|
||||
@api.depends('integral_lot_id')
|
||||
def _compute_integral_product_id(self):
|
||||
for item in self:
|
||||
if item.integral_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search(
|
||||
[('barcode', '=', item.integral_freight_barcode)])
|
||||
if location:
|
||||
item.integral_product_id = location.product_id.id
|
||||
else:
|
||||
item.integral_product_id = False
|
||||
if item.integral_lot_id:
|
||||
item.integral_product_id = item.integral_lot_id.product_id.id
|
||||
|
||||
# =================刀片型号=============
|
||||
blade_freight_barcode = fields.Char('刀片货位')
|
||||
blade_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀片货位')
|
||||
blade_lot_id = fields.Many2one('stock.lot', string='刀片批次')
|
||||
blade_product_id = fields.Many2one('product.product', string='刀片名称', compute='_compute_blade_product_id',
|
||||
store=True)
|
||||
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
|
||||
@@ -445,18 +444,15 @@ class FunctionalToolAssembly(models.Model):
|
||||
related='blade_product_id.specification_id')
|
||||
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_product_id.brand_id')
|
||||
|
||||
@api.depends('blade_freight_barcode')
|
||||
@api.depends('blade_lot_id')
|
||||
def _compute_blade_product_id(self):
|
||||
for item in self:
|
||||
if item.blade_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.blade_freight_barcode)])
|
||||
if location:
|
||||
item.blade_product_id = location.product_id.id
|
||||
else:
|
||||
item.blade_product_id = False
|
||||
if item.blade_lot_id:
|
||||
item.blade_product_id = item.blade_lot_id.product_id.id
|
||||
|
||||
# ==============刀杆型号================
|
||||
bar_freight_barcode = fields.Char('刀杆货位')
|
||||
bar_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀杆货位')
|
||||
bar_lot_id = fields.Many2one('stock.lot', string='刀杆批次')
|
||||
bar_product_id = fields.Many2one('product.product', string='刀杆名称', compute='_compute_bar_product_id',
|
||||
store=True)
|
||||
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
|
||||
@@ -465,18 +461,15 @@ class FunctionalToolAssembly(models.Model):
|
||||
related='bar_product_id.specification_id')
|
||||
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_product_id.brand_id')
|
||||
|
||||
@api.depends('bar_freight_barcode')
|
||||
@api.depends('bar_lot_id')
|
||||
def _compute_bar_product_id(self):
|
||||
for item in self:
|
||||
if item.bar_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.bar_freight_barcode)])
|
||||
if location:
|
||||
item.bar_product_id = location.product_id.id
|
||||
else:
|
||||
item.bar_product_id = False
|
||||
if item.bar_lot_id:
|
||||
item.bar_product_id = item.bar_lot_id.product_id.id
|
||||
|
||||
# =============刀盘型号================
|
||||
pad_freight_barcode = fields.Char('刀盘货位')
|
||||
pad_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀盘货位')
|
||||
pad_lot_id = fields.Many2one('stock.lot', string='刀盘批次')
|
||||
pad_product_id = fields.Many2one('product.product', string='刀盘名称', compute='_compute_pad_product_id',
|
||||
store=True)
|
||||
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
|
||||
@@ -485,15 +478,11 @@ class FunctionalToolAssembly(models.Model):
|
||||
related='pad_product_id.specification_id')
|
||||
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_product_id.brand_id')
|
||||
|
||||
@api.depends('pad_freight_barcode')
|
||||
@api.depends('pad_lot_id')
|
||||
def _compute_pad_product_id(self):
|
||||
for item in self:
|
||||
if item.pad_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.pad_freight_barcode)])
|
||||
if location:
|
||||
item.pad_product_id = location.product_id.id
|
||||
else:
|
||||
item.pad_product_id = False
|
||||
if item.pad_lot_id:
|
||||
item.pad_product_id = item.pad_lot_id.product_id.id
|
||||
|
||||
# ==============刀柄型号==============
|
||||
handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_handle_product_id', store=True)
|
||||
@@ -517,7 +506,8 @@ class FunctionalToolAssembly(models.Model):
|
||||
item.handle_freight_rfid = False
|
||||
|
||||
# ==============夹头型号==============
|
||||
chuck_freight_barcode = fields.Char('夹头货位')
|
||||
chuck_freight_barcode_id = fields.Many2one('sf.shelf.location', string='夹头货位')
|
||||
chuck_lot_id = fields.Many2one('stock.lot', string='夹头批次')
|
||||
chuck_product_id = fields.Many2one('product.product', string='夹头名称', compute='_compute_chuck_product_id',
|
||||
store=True)
|
||||
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
|
||||
@@ -526,17 +516,18 @@ class FunctionalToolAssembly(models.Model):
|
||||
related='chuck_product_id.specification_id')
|
||||
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_product_id.brand_id')
|
||||
|
||||
@api.depends('chuck_freight_barcode')
|
||||
@api.depends('chuck_lot_id')
|
||||
def _compute_chuck_product_id(self):
|
||||
for item in self:
|
||||
if item.chuck_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.chuck_freight_barcode)])
|
||||
if location:
|
||||
item.chuck_product_id = location.product_id.id
|
||||
else:
|
||||
item.chuck_product_id = False
|
||||
if item.chuck_lot_id:
|
||||
item.chuck_product_id = item.chuck_lot_id.product_id.id
|
||||
|
||||
# ==================待删除字段==================
|
||||
integral_freight_barcode = fields.Char('整体式刀具货位')
|
||||
blade_freight_barcode = fields.Char('刀片货位')
|
||||
bar_freight_barcode = fields.Char('刀杆货位')
|
||||
pad_freight_barcode = fields.Char('刀盘货位')
|
||||
chuck_freight_barcode = fields.Char('夹头货位')
|
||||
blade_name = fields.Char('')
|
||||
integral_name = fields.Char('')
|
||||
blade_code_id = fields.Many2one('stock.lot', '刀片序列号')
|
||||
@@ -679,7 +670,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
|
||||
class FunctionalToolDismantle(models.Model):
|
||||
_name = 'sf.functional.tool.dismantle'
|
||||
_inherit = ["barcodes.barcode_events_mixin"]
|
||||
_inherit = ["barcodes.barcode_events_mixin", 'mail.thread']
|
||||
_description = '功能刀具拆解'
|
||||
|
||||
def on_barcode_scanned(self, barcode):
|
||||
@@ -740,6 +731,22 @@ class FunctionalToolDismantle(models.Model):
|
||||
raise ValidationError('该功能刀具因为%s拆解,无需录入库位' % self.dismantle_cause)
|
||||
|
||||
name = fields.Char('名称', related='functional_tool_id.name')
|
||||
code = fields.Char('拆解单号', default=lambda self: self._get_code(), readonly=True)
|
||||
|
||||
def _get_code(self):
|
||||
"""
|
||||
自动生成拆解单编码
|
||||
"""
|
||||
new_time = str(fields.Date.today())
|
||||
datetime = new_time[2:4] + new_time[5:7] + new_time[-2:]
|
||||
functional_tool_dismantle = self.env['sf.functional.tool.dismantle'].sudo().search(
|
||||
[('code', 'ilike', datetime)], limit=1, order="id desc")
|
||||
if not functional_tool_dismantle:
|
||||
num = "%03d" % 1
|
||||
else:
|
||||
m = int(functional_tool_dismantle.code[-3:]) + 1
|
||||
num = "%03d" % m
|
||||
return 'GNDJ-CJD-%s-%s' % (datetime, num)
|
||||
|
||||
functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True,
|
||||
domain=[('functional_tool_status', '!=', '已拆除')])
|
||||
@@ -753,7 +760,7 @@ class FunctionalToolDismantle(models.Model):
|
||||
|
||||
dismantle_cause = fields.Selection(
|
||||
[('寿命到期报废', '寿命到期报废'), ('崩刀报废', '崩刀报废'), ('更换为其他刀具', '更换为其他刀具'),
|
||||
('刀具需磨削', '刀具需磨削')], string='拆解原因', required=True)
|
||||
('刀具需磨削', '刀具需磨削')], string='拆解原因', required=True, tracking=True)
|
||||
dismantle_data = fields.Datetime('拆解日期', readonly=True)
|
||||
dismantle_person = fields.Char('拆解人', readonly=True)
|
||||
image = fields.Binary('图片', readonly=True)
|
||||
@@ -761,7 +768,7 @@ class FunctionalToolDismantle(models.Model):
|
||||
scrap_id = fields.Char('报废单号', readonly=True)
|
||||
grinding_id = fields.Char('磨削单号', readonly=True)
|
||||
|
||||
state = fields.Selection([('待拆解', '待拆解'), ('已拆解', '已拆解')], default='待拆解')
|
||||
state = fields.Selection([('待拆解', '待拆解'), ('已拆解', '已拆解')], default='待拆解', tracking=True)
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
# 刀柄
|
||||
@@ -771,7 +778,9 @@ class FunctionalToolDismantle(models.Model):
|
||||
related='handle_product_id.cutting_tool_model_id')
|
||||
handle_brand_id = fields.Many2one('sf.machine.brand', string='刀柄品牌', related='handle_product_id.brand_id')
|
||||
handle_rfid = fields.Char(string='刀柄Rfid', compute='_compute_functional_tool_num', store=True)
|
||||
scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False)
|
||||
handle_lot_id = fields.Many2one('stock.lot', string='刀柄序列号', compute='_compute_functional_tool_num',
|
||||
store=True)
|
||||
scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False, tracking=True)
|
||||
|
||||
# 整体式
|
||||
integral_product_id = fields.Many2one('product.product', string='整体式刀具',
|
||||
@@ -780,6 +789,8 @@ class FunctionalToolDismantle(models.Model):
|
||||
related='integral_product_id.cutting_tool_model_id')
|
||||
integral_brand_id = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
|
||||
related='integral_product_id.brand_id')
|
||||
integral_lot_id = fields.Many2one('stock.lot', string='整体式刀具批次', compute='_compute_functional_tool_num',
|
||||
store=True)
|
||||
integral_freight_id = fields.Many2one('sf.shelf.location', '整体式刀具目标货位',
|
||||
domain="[('product_id', 'in', (integral_product_id, False))]")
|
||||
|
||||
@@ -789,6 +800,7 @@ class FunctionalToolDismantle(models.Model):
|
||||
blade_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
|
||||
related='blade_product_id.cutting_tool_model_id')
|
||||
blade_brand_id = fields.Many2one('sf.machine.brand', string='刀片品牌', related='blade_product_id.brand_id')
|
||||
blade_lot_id = fields.Many2one('stock.lot', string='刀片批次', compute='_compute_functional_tool_num', store=True)
|
||||
blade_freight_id = fields.Many2one('sf.shelf.location', '刀片目标货位',
|
||||
domain="[('product_id', 'in', (blade_product_id, False))]")
|
||||
|
||||
@@ -798,6 +810,7 @@ class FunctionalToolDismantle(models.Model):
|
||||
bar_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
|
||||
related='bar_product_id.cutting_tool_model_id')
|
||||
bar_brand_id = fields.Many2one('sf.machine.brand', string='刀杆品牌', related='bar_product_id.brand_id')
|
||||
bar_lot_id = fields.Many2one('stock.lot', string='刀杆批次', compute='_compute_functional_tool_num', store=True)
|
||||
bar_freight_id = fields.Many2one('sf.shelf.location', '刀杆目标货位',
|
||||
domain="[('product_id', 'in', (bar_product_id, False))]")
|
||||
|
||||
@@ -807,6 +820,7 @@ class FunctionalToolDismantle(models.Model):
|
||||
pad_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
|
||||
related='pad_product_id.cutting_tool_model_id')
|
||||
pad_brand_id = fields.Many2one('sf.machine.brand', string='刀盘品牌', related='pad_product_id.brand_id')
|
||||
pad_lot_id = fields.Many2one('stock.lot', string='刀盘批次', compute='_compute_functional_tool_num', store=True)
|
||||
pad_freight_id = fields.Many2one('sf.shelf.location', '刀盘目标货位',
|
||||
domain="[('product_id', 'in', (pad_product_id, False))]")
|
||||
|
||||
@@ -816,6 +830,7 @@ class FunctionalToolDismantle(models.Model):
|
||||
chuck_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
|
||||
related='chuck_product_id.cutting_tool_model_id')
|
||||
chuck_brand_id = fields.Many2one('sf.machine.brand', string='夹头品牌', related='chuck_product_id.brand_id')
|
||||
chuck_lot_id = fields.Many2one('stock.lot', string='夹头批次', compute='_compute_functional_tool_num', store=True)
|
||||
chuck_freight_id = fields.Many2one('sf.shelf.location', '夹头目标货位',
|
||||
domain="[('product_id', 'in', (chuck_product_id, False))]")
|
||||
|
||||
@@ -839,12 +854,20 @@ class FunctionalToolDismantle(models.Model):
|
||||
item.rfid = item.functional_tool_id.rfid
|
||||
item.handle_rfid = item.functional_tool_id.rfid
|
||||
|
||||
# 产品
|
||||
item.handle_product_id = item.functional_tool_id.functional_tool_name_id.handle_product_id.id
|
||||
item.integral_product_id = item.functional_tool_id.functional_tool_name_id.integral_product_id.id
|
||||
item.blade_product_id = item.functional_tool_id.functional_tool_name_id.blade_product_id.id
|
||||
item.bar_product_id = item.functional_tool_id.functional_tool_name_id.bar_product_id.id
|
||||
item.pad_product_id = item.functional_tool_id.functional_tool_name_id.pad_product_id.id
|
||||
item.chuck_product_id = item.functional_tool_id.functional_tool_name_id.chuck_product_id.id
|
||||
# 批次/序列号
|
||||
item.handle_lot_id = item.functional_tool_id.functional_tool_name_id.handle_code_id.id
|
||||
item.integral_lot_id = item.functional_tool_id.functional_tool_name_id.integral_lot_id.id
|
||||
item.blade_lot_id = item.functional_tool_id.functional_tool_name_id.blade_lot_id.id
|
||||
item.bar_lot_id = item.functional_tool_id.functional_tool_name_id.bar_lot_id.id
|
||||
item.pad_lot_id = item.functional_tool_id.functional_tool_name_id.pad_lot_id.id
|
||||
item.chuck_lot_id = item.functional_tool_id.functional_tool_name_id.chuck_lot_id.id
|
||||
else:
|
||||
item.tool_groups_id = False
|
||||
item.tool_type_id = False
|
||||
@@ -860,14 +883,45 @@ class FunctionalToolDismantle(models.Model):
|
||||
item.pad_product_id = False
|
||||
item.chuck_product_id = False
|
||||
|
||||
item.handle_lot_id = False
|
||||
item.integral_lot_id = False
|
||||
item.blade_lot_id = False
|
||||
item.bar_lot_id = False
|
||||
item.pad_lot_id = False
|
||||
item.chuck_lot_id = False
|
||||
|
||||
def location_duplicate_check(self):
|
||||
"""
|
||||
目标货位去重校验
|
||||
"""
|
||||
if self.blade_freight_id:
|
||||
if self.bar_freight_id:
|
||||
if self.blade_freight_id == self.bar_freight_id:
|
||||
raise ValidationError('【刀片】和【刀杆】的目标货位重复,请重新选择!')
|
||||
elif self.pad_freight_id:
|
||||
if self.blade_freight_id == self.pad_freight_id:
|
||||
raise ValidationError('【刀片】和【刀盘】的目标货位重复,请重新选择!')
|
||||
if self.chuck_freight_id:
|
||||
if self.chuck_freight_id == self.integral_freight_id:
|
||||
raise ValidationError('【夹头】和【整体式刀具】的目标货位重复,请重新选择!')
|
||||
if self.chuck_freight_id == self.blade_freight_id:
|
||||
raise ValidationError('【夹头】和【刀片】的目标货位重复,请重新选择!')
|
||||
if self.chuck_freight_id == self.bar_freight_id:
|
||||
raise ValidationError('【夹头】和【刀杆】的目标货位重复,请重新选择!')
|
||||
if self.chuck_freight_id == self.pad_freight_id:
|
||||
raise ValidationError('【夹头】和【刀盘】的目标货位重复,请重新选择!')
|
||||
|
||||
def confirmation_disassembly(self):
|
||||
logging.info('%s刀具确认开始拆解' % self.dismantle_cause)
|
||||
code = self.code
|
||||
if self.functional_tool_id.functional_tool_status == '已拆除':
|
||||
raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle)
|
||||
# 对拆解的功能刀具进行校验,只有在刀具房的功能刀具才能拆解
|
||||
if self.functional_tool_id.tool_room_num == 0:
|
||||
raise ValidationError('Rfid为【%s】的功能刀具当前位置为【%s】,不能进行拆解!' % (
|
||||
self.rfid, self.functional_tool_id.current_location))
|
||||
# 目标重复校验
|
||||
self.location_duplicate_check()
|
||||
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
||||
location_dest = self.env['stock.location'].search([('name', '=', '刀具房')])
|
||||
# =================刀柄是否[报废]拆解=======
|
||||
@@ -879,53 +933,62 @@ class FunctionalToolDismantle(models.Model):
|
||||
functional_tool_assembly = self.functional_tool_id.functional_tool_name_id
|
||||
if self.scrap_boolean:
|
||||
# 刀柄报废 入库到Scrap
|
||||
lot.create_stock_quant(location, location_dest_scrap, functional_tool_assembly.id, '功能刀具拆解',
|
||||
lot.create_stock_quant(location, location_dest_scrap, functional_tool_assembly.id, code,
|
||||
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
|
||||
else:
|
||||
# 刀柄不报废 入库到刀具房
|
||||
lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, '功能刀具拆解',
|
||||
lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, code,
|
||||
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
|
||||
# ==============功能刀具[报废]拆解================
|
||||
if self.dismantle_cause in ['寿命到期报废', '崩刀报废']:
|
||||
# 除刀柄外物料报废 入库到Scrap
|
||||
if self.integral_product_id:
|
||||
self.integral_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
||||
self.integral_product_id.dismantle_stock_moves(False, self.integral_lot_id, location,
|
||||
location_dest_scrap, code)
|
||||
elif self.blade_product_id:
|
||||
self.blade_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
||||
self.blade_product_id.dismantle_stock_moves(False, self.blade_lot_id, location, location_dest_scrap,
|
||||
code)
|
||||
if self.bar_product_id:
|
||||
self.bar_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
||||
self.bar_product_id.dismantle_stock_moves(False, self.bar_lot_id, location, location_dest_scrap,
|
||||
code)
|
||||
elif self.pad_product_id:
|
||||
self.pad_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
||||
self.pad_product_id.dismantle_stock_moves(False, self.pad_lot_id, location, location_dest_scrap,
|
||||
code)
|
||||
if self.chuck_product_id:
|
||||
self.chuck_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
|
||||
self.chuck_product_id.dismantle_stock_moves(False, self.chuck_lot_id, location, location_dest_scrap,
|
||||
code)
|
||||
# ===========功能刀具[磨削]拆解==============
|
||||
elif self.dismantle_cause in ['刀具需磨削']:
|
||||
location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
|
||||
# 除刀柄外物料拆解 入库到具体库位
|
||||
if self.integral_product_id:
|
||||
self.integral_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
elif self.blade_product_id:
|
||||
self.blade_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
if self.bar_product_id:
|
||||
self.bar_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
elif self.pad_product_id:
|
||||
self.pad_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
if self.chuck_product_id:
|
||||
self.chuck_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
# ==============功能刀具[更换]拆解==============
|
||||
elif self.dismantle_cause in ['更换为其他刀具']:
|
||||
# 除刀柄外物料拆解 入库到具体库位
|
||||
# elif self.dismantle_cause in ['刀具需磨削']:
|
||||
# location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
|
||||
# # 除刀柄外物料拆解 入库到具体库位
|
||||
# if self.integral_product_id:
|
||||
# self.integral_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
# elif self.blade_product_id:
|
||||
# self.blade_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
# if self.bar_product_id:
|
||||
# self.bar_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
# elif self.pad_product_id:
|
||||
# self.pad_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
# if self.chuck_product_id:
|
||||
# self.chuck_product_id.dismantle_stock_moves(False, location, location_dest)
|
||||
# ==============功能刀具[更换,磨削]拆解==============
|
||||
elif self.dismantle_cause in ['更换为其他刀具', '刀具需磨削']:
|
||||
# 除刀柄外物料拆解 入库到具体货位
|
||||
if self.integral_freight_id:
|
||||
self.integral_product_id.dismantle_stock_moves(self.integral_freight_id.barcode, location,
|
||||
location_dest)
|
||||
self.integral_product_id.dismantle_stock_moves(self.integral_freight_id, self.integral_lot_id, location,
|
||||
location_dest, code)
|
||||
elif self.blade_freight_id:
|
||||
self.blade_product_id.dismantle_stock_moves(self.blade_freight_id.barcode, location, location_dest)
|
||||
self.blade_product_id.dismantle_stock_moves(self.blade_freight_id, self.blade_lot_id, location,
|
||||
location_dest, code)
|
||||
if self.bar_freight_id:
|
||||
self.bar_product_id.dismantle_stock_moves(self.bar_freight_id.barcode, location, location_dest)
|
||||
self.bar_product_id.dismantle_stock_moves(self.bar_freight_id, self.bar_lot_id, location,
|
||||
location_dest, code)
|
||||
elif self.pad_freight_id:
|
||||
self.pad_product_id.dismantle_stock_moves(self.pad_freight_id.barcode, location, location_dest)
|
||||
self.pad_product_id.dismantle_stock_moves(self.pad_freight_id, self.pad_lot_id, location,
|
||||
location_dest, code)
|
||||
if self.chuck_freight_id:
|
||||
self.chuck_product_id.dismantle_stock_moves(self.chuck_freight_id.barcode, location, location_dest)
|
||||
self.chuck_product_id.dismantle_stock_moves(self.chuck_freight_id, self.chuck_lot_id, location,
|
||||
location_dest, code)
|
||||
# ===============删除功能刀具的Rfid字段的值, 赋值给Rfid(已拆解)字段=====
|
||||
self.functional_tool_id.write({
|
||||
'rfid_dismantle': self.functional_tool_id.rfid,
|
||||
@@ -946,26 +1009,22 @@ class FunctionalToolDismantle(models.Model):
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
def dismantle_stock_moves(self, shelf_location_barcode, location_id, location_dest_id):
|
||||
def dismantle_stock_moves(self, shelf_location_id, lot_id, location_id, location_dest_id, code):
|
||||
# 创建功能刀具拆解单产品库存移动记录
|
||||
stock_move_id = self.env['stock.move'].sudo().create({
|
||||
'name': '功能刀具拆解',
|
||||
'name': code,
|
||||
'product_id': self.id,
|
||||
'location_id': location_id.id,
|
||||
'location_dest_id': location_dest_id.id,
|
||||
'product_uom_qty': 1.00,
|
||||
'state': 'done'
|
||||
})
|
||||
if shelf_location_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', shelf_location_barcode)])
|
||||
location.product_num = location.product_num + 1
|
||||
else:
|
||||
location = self.env['sf.shelf.location']
|
||||
# 创建移动历史记录
|
||||
stock_move_line_id = self.env['stock.move.line'].sudo().create({
|
||||
'product_id': self.id,
|
||||
'lot_id': lot_id.id,
|
||||
'move_id': stock_move_id.id,
|
||||
'current_location_id': location.id,
|
||||
'destination_location_id': shelf_location_id.id,
|
||||
'install_tool_time': fields.Datetime.now(),
|
||||
'qty_done': 1.0,
|
||||
'state': 'done',
|
||||
|
||||
@@ -21,7 +21,7 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
name = fields.Char('名称')
|
||||
tool_name_id = fields.Many2one('sf.tool.inventory', '功能刀具名称')
|
||||
sf_cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具型号')
|
||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
|
||||
barcode_id = fields.Many2one('stock.lot', string='序列号', readonly=True)
|
||||
sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型',
|
||||
group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True)
|
||||
|
||||
@@ -318,6 +318,7 @@ class StockMoveLine(models.Model):
|
||||
|
||||
class RealTimeDistributionOfFunctionalTools(models.Model):
|
||||
_name = 'sf.real.time.distribution.of.functional.tools'
|
||||
_inherit = ['mail.thread']
|
||||
_description = '功能刀具安全库存'
|
||||
|
||||
name = fields.Char('名称', readonly=True, compute='_compute_name', store=True)
|
||||
@@ -331,11 +332,11 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
|
||||
side_shelf_num = fields.Integer(string='线边刀库数量')
|
||||
on_tool_stock_num = fields.Integer(string='机内刀库数量')
|
||||
tool_stock_total = fields.Integer(string='当前库存量', readonly=True)
|
||||
min_stock_num = fields.Integer('最低库存量')
|
||||
max_stock_num = fields.Integer('最高库存量')
|
||||
min_stock_num = fields.Integer('最低库存量', tracking=True)
|
||||
max_stock_num = fields.Integer('最高库存量', tracking=True)
|
||||
batch_replenishment_num = fields.Integer('批次补货量', readonly=True, compute='_compute_batch_replenishment_num',
|
||||
store=True)
|
||||
unit = fields.Char('单位')
|
||||
unit = fields.Char('单位', default="件")
|
||||
image = fields.Binary('图片', readonly=False)
|
||||
|
||||
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False)
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="barcode_id" invisible="1"/>
|
||||
<field name="barcode_id" invisible="0"/>
|
||||
<field name="rfid" readonly="1"
|
||||
attrs="{'invisible': [('functional_tool_status', '=', '已拆除')]}"/>
|
||||
<field name="rfid_dismantle" readonly="1"
|
||||
@@ -115,7 +115,7 @@
|
||||
options="{'no_create': True, 'no_quick_create': True}"/>
|
||||
<field name="cutting_tool_cutterhead_model_id"
|
||||
options="{'no_create': True, 'no_quick_create': True}"/>
|
||||
<field name="safe_inventory_id" readonly="0"/>
|
||||
<field name="safe_inventory_id" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="image" nolabel="1" widget="image"/>
|
||||
@@ -411,6 +411,10 @@
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids"/>
|
||||
<field name="message_ids"/>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -376,6 +376,10 @@
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids"/>
|
||||
<field name="message_ids"/>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -464,8 +468,8 @@
|
||||
<field name="arch" type="xml">
|
||||
<form create="0" delete="0" edit="0">
|
||||
<header>
|
||||
<!-- <button string="修改编码" name="put_assembly_order_code" type="object"-->
|
||||
<!-- class="btn-primary" confirm="是否确认修改编码"/>-->
|
||||
<!-- <button string="修改编码" name="put_assembly_order_code" type="object"-->
|
||||
<!-- class="btn-primary" confirm="是否确认修改编码"/>-->
|
||||
<button string="组装" name="put_start_preset" type="object"
|
||||
attrs="{'invisible': [('assemble_status', '!=', '0')]}"
|
||||
class="btn-primary"/>
|
||||
@@ -528,8 +532,10 @@
|
||||
<field name="after_assembly_max_lifetime_value"
|
||||
string="最大寿命值(min)"/>
|
||||
<field name="after_assembly_alarm_value" string="报警值(min)"/>
|
||||
<field name="after_assembly_used_value" string="已使用值(min)" invisible="1"/>
|
||||
<field name="after_assembly_effective_length" string="有效长(mm)" invisible="1"/>
|
||||
<field name="after_assembly_used_value" string="已使用值(min)"
|
||||
invisible="1"/>
|
||||
<field name="after_assembly_effective_length" string="有效长(mm)"
|
||||
invisible="1"/>
|
||||
<field name="L_D_number" invisible="1"/>
|
||||
<field name="hiding_length" invisible="1"/>
|
||||
</group>
|
||||
@@ -551,13 +557,14 @@
|
||||
<field name="sf_tool_brand_id_5" string="品牌"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="1" attrs="{'invisible': [('chuck_freight_barcode', '=', False)]}">
|
||||
<group col="1" attrs="{'invisible': [('chuck_freight_barcode_id', '=', False)]}">
|
||||
<div>
|
||||
<separator string="夹头:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="chuck_freight_barcode" string="货位"/>
|
||||
<field name="chuck_freight_barcode_id" string="货位"/>
|
||||
<field name="chuck_lot_id" string="批次"/>
|
||||
<field name="chuck_product_id" string="名称"/>
|
||||
<field name="cutting_tool_cutterhead_model_id" string="型号"/>
|
||||
<field name="chuck_specification_id" string="规格"/>
|
||||
@@ -569,24 +576,27 @@
|
||||
<group>
|
||||
<group col="1">
|
||||
<group col="1"
|
||||
attrs="{'invisible': [('integral_freight_barcode', '=', False)]}">
|
||||
attrs="{'invisible': [('integral_freight_barcode_id', '=', False)]}">
|
||||
<div>
|
||||
<separator string="整体式刀具:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<field name="integral_freight_barcode" string="货位"/>
|
||||
<field name="integral_freight_barcode_id" string="货位"/>
|
||||
<field name="integral_lot_id" string="批次"/>
|
||||
<field name="integral_product_id" string="名称"/>
|
||||
<field name="cutting_tool_integral_model_id" string="型号"/>
|
||||
<field name="integral_specification_id" string="规格"/>
|
||||
<field name="sf_tool_brand_id_1" string="品牌"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="1" attrs="{'invisible': [('blade_freight_barcode', '=', False)]}">
|
||||
<group col="1"
|
||||
attrs="{'invisible': [('blade_freight_barcode_id', '=', False)]}">
|
||||
<div>
|
||||
<separator string="刀片:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<field name="blade_freight_barcode" string="货位"/>
|
||||
<field name="blade_freight_barcode_id" string="货位"/>
|
||||
<field name="blade_lot_id" string="批次"/>
|
||||
<field name="blade_product_id" string="名称"/>
|
||||
<field name="cutting_tool_blade_model_id" string="型号"/>
|
||||
<field name="blade_specification_id" string="规格"/>
|
||||
@@ -595,13 +605,14 @@
|
||||
</group>
|
||||
</group>
|
||||
<group col="1">
|
||||
<group col="1" attrs="{'invisible': [('bar_freight_barcode', '=', False)]}">
|
||||
<group col="1" attrs="{'invisible': [('bar_freight_barcode_id', '=', False)]}">
|
||||
<div>
|
||||
<separator string="刀杆:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="bar_freight_barcode" string="货位"/>
|
||||
<field name="bar_freight_barcode_id" string="货位"/>
|
||||
<field name="bar_lot_id" string="批次"/>
|
||||
<field name="bar_product_id" string="名称"/>
|
||||
<field name="cutting_tool_cutterbar_model_id" string="型号"/>
|
||||
<field name="bar_specification_id" string="规格"/>
|
||||
@@ -609,13 +620,14 @@
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group col="1" attrs="{'invisible': [('pad_freight_barcode', '=', False)]}">
|
||||
<group col="1" attrs="{'invisible': [('pad_freight_barcode_id', '=', False)]}">
|
||||
<div>
|
||||
<separator string="刀盘:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="pad_freight_barcode" string="货位"/>
|
||||
<field name="pad_freight_barcode_id" string="货位"/>
|
||||
<field name="pad_lot_id" string="批次"/>
|
||||
<field name="pad_product_id" string="名称"/>
|
||||
<field name="cutting_tool_cutterpad_model_id" string="型号"/>
|
||||
<field name="pad_specification_id" string="规格"/>
|
||||
@@ -668,6 +680,10 @@
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids"/>
|
||||
<field name="message_ids"/>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -722,6 +738,7 @@
|
||||
<field name="model">sf.functional.tool.dismantle</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree create="1">
|
||||
<field name="code"/>
|
||||
<field name="rfid"/>
|
||||
<field name="functional_tool_id"/>
|
||||
<field name="tool_type_id" invisible="1"/>
|
||||
@@ -749,13 +766,14 @@
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
<field name="functional_tool_id" placeholder="请选择将要拆解的功能刀具"
|
||||
options="{'no_create': True}" attrs="{'readonly': [('state', '=', '已拆解')]}"/>
|
||||
<field name="code"/>
|
||||
</h1>
|
||||
</div>
|
||||
<field name="_barcode_scanned" widget="barcode_handler"/>
|
||||
<group>
|
||||
<group>
|
||||
<field name="functional_tool_id" placeholder="请选择将要拆解的功能刀具"
|
||||
options="{'no_create': True}" attrs="{'readonly': [('state', '=', '已拆解')]}"/>
|
||||
<field name="rfid" attrs="{'invisible': [('state', '=', '已拆解')]}"/>
|
||||
<field name="rfid_dismantle" attrs="{'invisible': [('state', '!=', '已拆解')]}"/>
|
||||
<field name="tool_type_id"/>
|
||||
@@ -786,91 +804,98 @@
|
||||
<group>
|
||||
<group string="刀柄" attrs="{'invisible': [('handle_product_id', '=', False)]}">
|
||||
<group>
|
||||
<field name="scrap_boolean" string="是否报废"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['寿命到期报废','崩刀报废'])], 'readonly': [('state', '=', '已拆解')]}"/>
|
||||
<field name="handle_rfid" string="Rfid"/>
|
||||
<field name="handle_lot_id" string="序列号"/>
|
||||
<field name="handle_product_id" string="名称"/>
|
||||
<field name="handle_type_id" string="型号"/>
|
||||
<field name="handle_brand_id" string="品牌"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="handle_rfid" string="Rfid"/>
|
||||
<field name="scrap_boolean" string="是否报废"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['寿命到期报废','崩刀报废'])], 'readonly': [('state', '=', '已拆解')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="夹头"
|
||||
attrs="{'invisible': [('chuck_product_id', '=', False)]}">
|
||||
<group>
|
||||
<field name="chuck_freight_id" string="目标货位" placeholder="请选择"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具', '刀具需磨削'])], 'readonly': [('state', '=', '已拆解')],
|
||||
'required': [('chuck_lot_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具', '刀具需磨削'])]}"/>
|
||||
<field name="chuck_lot_id" string="批次"/>
|
||||
<field name="chuck_product_id" string="名称"/>
|
||||
<field name="chuck_type_id" string="型号"/>
|
||||
<field name="chuck_brand_id" string="品牌"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="chuck_freight_id" string="目标货位"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')],
|
||||
'required': [('chuck_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group attrs="{'invisible': [('integral_product_id', '=', False)]}">
|
||||
<group string="整体式刀具">
|
||||
<group>
|
||||
<field name="integral_freight_id" string="目标货位" placeholder="请选择"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具', '刀具需磨削'])], 'readonly': [('state', '=', '已拆解')],
|
||||
'required': [('integral_lot_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具', '刀具需磨削'])]}"/>
|
||||
<field name="integral_lot_id" string="批次"/>
|
||||
<field name="integral_product_id" string="名称"/>
|
||||
<field name="integral_type_id" string="型号"/>
|
||||
<field name="integral_brand_id" string="品牌"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="integral_freight_id" string="目标货位"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')],
|
||||
'required': [('integral_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/>
|
||||
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group string="刀片" attrs="{'invisible': [('blade_product_id', '=', False)]}">
|
||||
<group>
|
||||
<field name="blade_freight_id" string="目标货位" placeholder="请选择"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具', '刀具需磨削'])], 'readonly': [('state', '=', '已拆解')],
|
||||
'required': [('blade_lot_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具', '刀具需磨削'])]}"/>
|
||||
<field name="blade_lot_id" string="批次"/>
|
||||
<field name="blade_product_id" string="名称"/>
|
||||
<field name="blade_type_id" string="型号"/>
|
||||
<field name="blade_brand_id" string="品牌"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="blade_freight_id" string="目标货位"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')],
|
||||
'required': [('blade_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="刀杆" attrs="{'invisible': [('bar_product_id', '=', False)]}">
|
||||
<group>
|
||||
<field name="bar_freight_id" string="目标货位" placeholder="请选择"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具', '刀具需磨削'])], 'readonly': [('state', '=', '已拆解')],
|
||||
'required': [('bar_lot_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具', '刀具需磨削'])]}"/>
|
||||
<field name="bar_lot_id" string="批次"/>
|
||||
<field name="bar_product_id" string="名称"/>
|
||||
<field name="bar_type_id" string="型号"/>
|
||||
<field name="bar_brand_id" string="品牌"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="bar_freight_id" string="目标货位"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')],
|
||||
'required': [('bar_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="刀盘" attrs="{'invisible': [('pad_product_id', '=', False)]}">
|
||||
<group>
|
||||
<field name="pad_freight_id" string="目标货位" placeholder="请选择"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具', '刀具需磨削'])], 'readonly': [('state', '=', '已拆解')],
|
||||
'required': [('pad_lot_id', '!=', False), ('dismantle_cause', 'in', ['更换为其他刀具', '刀具需磨削'])]}"/>
|
||||
<field name="pad_lot_id" string="批次"/>
|
||||
<field name="pad_product_id" string="名称"/>
|
||||
<field name="pad_type_id" string="型号"/>
|
||||
<field name="pad_brand_id" string="品牌"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="pad_freight_id" string="目标货位"
|
||||
options="{'no_create': True,'no_create_edit':True}"
|
||||
attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')],
|
||||
'required': [('pad_product_id', '!=', False), ('dismantle_cause', 'in', ['更换为其他刀具'])]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
<page string="其他">
|
||||
<group>
|
||||
<group>
|
||||
<field name="dismantle_person"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="dismantle_data"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids"/>
|
||||
<field name="message_ids"/>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -880,6 +905,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="functional_tool_id"/>
|
||||
<field name="code" string="拆解单编码"/>
|
||||
<filter name="no_dismantle_state" string="未拆解" domain="[('state','!=','已拆解')]"/>
|
||||
<filter name="dismantle_state" string="已拆解" domain="[('state','=','已拆解')]"/>
|
||||
<separator/>
|
||||
|
||||
@@ -233,7 +233,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
|
||||
# 功能刀具组装信息
|
||||
# ===============整体式刀具型号=================
|
||||
integral_freight_barcode = fields.Char('整体式刀具货位')
|
||||
integral_freight_barcode_id = fields.Many2one('sf.shelf.location', string='整体式刀具货位',
|
||||
domain="[('product_id.cutting_tool_material_id.name', '=', '整体式刀具'),('product_num', '>', 0)]")
|
||||
integral_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='整体式刀具批次',
|
||||
domain="[('shelf_location_id', '=', integral_freight_barcode_id)]")
|
||||
integral_product_id = fields.Many2one('product.product', string='整体式刀具名称',
|
||||
compute='_compute_integral_product_id', store=True)
|
||||
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
|
||||
@@ -243,28 +246,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
|
||||
related='integral_product_id.brand_id')
|
||||
|
||||
@api.depends('integral_freight_barcode')
|
||||
@api.onchange('integral_freight_barcode_id')
|
||||
def _onchange_integral_freight_barcode_id(self):
|
||||
for item in self:
|
||||
item.integral_freight_lot_id = False
|
||||
|
||||
@api.depends('integral_freight_lot_id')
|
||||
def _compute_integral_product_id(self):
|
||||
if self.integral_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)])
|
||||
if location:
|
||||
if not location.product_id:
|
||||
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
|
||||
else:
|
||||
material_name_id = location.product_id.cutting_tool_material_id
|
||||
if material_name_id and material_name_id.name == '整体式刀具':
|
||||
if location.product_num == 0:
|
||||
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
|
||||
self.integral_product_id = location.product_id.id
|
||||
else:
|
||||
raise ValidationError(
|
||||
'编码为【%s】的货位存放的产品为【%s】,不是整体式刀具,请重新选择!' % (
|
||||
location.barcode, location.product_id.name))
|
||||
else:
|
||||
raise ValidationError('编码为【%s】的货位不存在!' % self.integral_freight_barcode)
|
||||
if self.integral_freight_lot_id:
|
||||
self.integral_product_id = self.integral_freight_lot_id.lot_id.product_id.id
|
||||
else:
|
||||
self.integral_product_id = False
|
||||
|
||||
# ===============刀片型号====================
|
||||
blade_freight_barcode = fields.Char('刀片货位')
|
||||
blade_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀片货位',
|
||||
domain="[('product_id.cutting_tool_material_id.name', '=', '刀片'),('product_num', '>', 0)]")
|
||||
blade_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='刀片批次',
|
||||
domain="[('shelf_location_id', '=', blade_freight_barcode_id)]")
|
||||
blade_product_id = fields.Many2one('product.product', string='刀片名称', compute='_compute_blade_product_id',
|
||||
store=True)
|
||||
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
|
||||
@@ -273,28 +271,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
related='blade_product_id.specification_id')
|
||||
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_product_id.brand_id')
|
||||
|
||||
@api.depends('blade_freight_barcode')
|
||||
@api.onchange('blade_freight_barcode_id')
|
||||
def _onchange_blade_freight_barcode_id(self):
|
||||
for item in self:
|
||||
item.blade_freight_lot_id = False
|
||||
|
||||
@api.depends('blade_freight_lot_id')
|
||||
def _compute_blade_product_id(self):
|
||||
if self.blade_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)])
|
||||
if location:
|
||||
if not location.product_id:
|
||||
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
|
||||
else:
|
||||
material_name_id = location.product_id.cutting_tool_material_id
|
||||
if material_name_id and material_name_id.name == '刀片':
|
||||
if location.product_num == 0:
|
||||
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
|
||||
self.blade_product_id = location.product_id.id
|
||||
else:
|
||||
raise ValidationError(
|
||||
'编码为【%s】的货位存放的产品为【%s】,不是刀片,请重新选择!' % (
|
||||
location.barcode, location.product_id.name))
|
||||
else:
|
||||
raise ValidationError('编码为【%s】的货位不存在!' % self.blade_freight_barcode)
|
||||
if self.blade_freight_lot_id:
|
||||
self.blade_product_id = self.blade_freight_lot_id.lot_id.product_id.id
|
||||
else:
|
||||
self.blade_product_id = False
|
||||
|
||||
# ====================刀杆型号==================
|
||||
bar_freight_barcode = fields.Char('刀杆货位')
|
||||
bar_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀杆货位',
|
||||
domain="[('product_id.cutting_tool_material_id.name', '=', '刀杆'),('product_num', '>', 0)]")
|
||||
bar_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='刀杆批次',
|
||||
domain="[('shelf_location_id', '=', bar_freight_barcode_id)]")
|
||||
bar_product_id = fields.Many2one('product.product', string='刀杆名称', compute='_compute_bar_product_id',
|
||||
store=True)
|
||||
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
|
||||
@@ -303,28 +296,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
related='bar_product_id.specification_id')
|
||||
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_product_id.brand_id')
|
||||
|
||||
@api.depends('bar_freight_barcode')
|
||||
@api.onchange('bar_freight_barcode_id')
|
||||
def _onchange_bar_freight_barcode_id(self):
|
||||
for item in self:
|
||||
item.bar_freight_lot_id = False
|
||||
|
||||
@api.depends('bar_freight_lot_id')
|
||||
def _compute_bar_product_id(self):
|
||||
if self.bar_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)])
|
||||
if location:
|
||||
if not location.product_id:
|
||||
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
|
||||
else:
|
||||
material_name_id = location.product_id.cutting_tool_material_id
|
||||
if material_name_id and material_name_id.name == '刀杆':
|
||||
if location.product_num == 0:
|
||||
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
|
||||
self.bar_product_id = location.product_id.id
|
||||
else:
|
||||
raise ValidationError(
|
||||
'编码为【%s】的货位存放的产品为【%s】,不是刀杆,请重新选择!' % (
|
||||
location.barcode, location.product_id.name))
|
||||
else:
|
||||
raise ValidationError('编码为【%s】的货位不存在!' % self.bar_freight_barcode)
|
||||
if self.bar_freight_lot_id:
|
||||
self.bar_product_id = self.bar_freight_lot_id.lot_id.product_id.id
|
||||
else:
|
||||
self.bar_product_id = False
|
||||
|
||||
# ===============刀盘型号===================
|
||||
pad_freight_barcode = fields.Char('刀盘货位')
|
||||
pad_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀盘货位',
|
||||
domain="[('product_id.cutting_tool_material_id.name', '=', '刀盘'),('product_num', '>', 0)]")
|
||||
pad_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='刀盘批次',
|
||||
domain="[('shelf_location_id', '=', pad_freight_barcode_id)]")
|
||||
pad_product_id = fields.Many2one('product.product', string='刀盘名称', compute='_compute_pad_product_id',
|
||||
store=True)
|
||||
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
|
||||
@@ -333,25 +321,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
related='pad_product_id.specification_id')
|
||||
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_product_id.brand_id')
|
||||
|
||||
@api.depends('pad_freight_barcode')
|
||||
@api.onchange('pad_freight_barcode_id')
|
||||
def _onchange_pad_freight_barcode_id(self):
|
||||
for item in self:
|
||||
item.pad_freight_lot_id = False
|
||||
|
||||
@api.depends('pad_freight_lot_id')
|
||||
def _compute_pad_product_id(self):
|
||||
if self.pad_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)])
|
||||
if location:
|
||||
if not location.product_id:
|
||||
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
|
||||
else:
|
||||
material_name_id = location.product_id.cutting_tool_material_id
|
||||
if material_name_id and material_name_id.name == '刀盘':
|
||||
if location.product_num == 0:
|
||||
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
|
||||
self.pad_product_id = location.product_id.id
|
||||
else:
|
||||
raise ValidationError(
|
||||
'编码为【%s】的货位存放的产品为【%s】,不是刀盘,请重新选择!' % (
|
||||
location.barcode, location.product_id.name))
|
||||
else:
|
||||
raise ValidationError('编码为【%s】的货位不存在!' % self.pad_freight_barcode)
|
||||
if self.pad_freight_lot_id:
|
||||
self.pad_product_id = self.pad_freight_lot_id.lot_id.product_id.id
|
||||
else:
|
||||
self.pad_product_id = False
|
||||
|
||||
# ================刀柄型号===============
|
||||
handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_rfid')
|
||||
@@ -374,7 +354,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
self.pad_product_id = False
|
||||
|
||||
# =================夹头型号==============
|
||||
chuck_freight_barcode = fields.Char('夹头货位')
|
||||
chuck_freight_barcode_id = fields.Many2one('sf.shelf.location', string='夹头货位',
|
||||
domain="[('product_id.cutting_tool_material_id.name', '=', '夹头'),('product_num', '>', 0)]")
|
||||
chuck_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='夹头批次',
|
||||
domain="[('shelf_location_id', '=', chuck_freight_barcode_id)]")
|
||||
chuck_product_id = fields.Many2one('product.product', string='夹头名称', compute='_compute_chuck_product_id',
|
||||
store=True)
|
||||
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
|
||||
@@ -383,25 +366,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
related='chuck_product_id.specification_id')
|
||||
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_product_id.brand_id')
|
||||
|
||||
@api.depends('chuck_freight_barcode')
|
||||
@api.onchange('chuck_freight_barcode_id')
|
||||
def _onchange_chuck_freight_barcode_id(self):
|
||||
for item in self:
|
||||
item.chuck_freight_lot_id = False
|
||||
|
||||
@api.depends('chuck_freight_lot_id')
|
||||
def _compute_chuck_product_id(self):
|
||||
if self.chuck_freight_barcode:
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)])
|
||||
if location:
|
||||
if not location.product_id:
|
||||
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
|
||||
else:
|
||||
material_name_id = location.product_id.cutting_tool_material_id
|
||||
if material_name_id and material_name_id.name == '夹头':
|
||||
if location.product_num == 0:
|
||||
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
|
||||
self.chuck_product_id = location.product_id.id
|
||||
else:
|
||||
raise ValidationError(
|
||||
'编码为【%s】的货位存放的产品为【%s】,不是夹头,请重新选择!' % (
|
||||
location.barcode, location.product_id.name))
|
||||
else:
|
||||
raise ValidationError('编码为【%s】的货位不存在!' % self.chuck_freight_barcode)
|
||||
if self.chuck_freight_lot_id:
|
||||
self.chuck_product_id = self.chuck_freight_lot_id.lot_id.product_id.id
|
||||
else:
|
||||
self.chuck_product_id = False
|
||||
|
||||
# ========================================
|
||||
def on_barcode_scanned(self, barcode):
|
||||
@@ -423,23 +398,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
if location:
|
||||
material_name = location.product_id.cutting_tool_material_id.name
|
||||
if material_name == '夹头':
|
||||
record.chuck_freight_barcode = barcode
|
||||
record.chuck_freight_barcode_id = location.id
|
||||
elif material_name == '整体式刀具':
|
||||
record.integral_freight_barcode = barcode
|
||||
record.blade_freight_barcode = ''
|
||||
record.bar_freight_barcode = ''
|
||||
record.pad_freight_barcode = ''
|
||||
record.integral_freight_barcode_id = location.id
|
||||
record.blade_freight_barcode_id = False
|
||||
record.bar_freight_barcode_id = False
|
||||
record.pad_freight_barcode_id = False
|
||||
elif material_name == '刀片':
|
||||
record.blade_freight_barcode = barcode
|
||||
record.integral_freight_barcode = ''
|
||||
record.blade_freight_barcode_id = location.id
|
||||
record.integral_freight_barcode_id = False
|
||||
elif material_name == '刀杆':
|
||||
record.bar_freight_barcode = barcode
|
||||
record.integral_freight_barcode = ''
|
||||
record.pad_freight_barcode = ''
|
||||
record.bar_freight_barcode_id = location.id
|
||||
record.integral_freight_barcode_id = False
|
||||
record.pad_freight_barcode_id = False
|
||||
elif material_name == '刀盘':
|
||||
record.pad_freight_barcode = barcode
|
||||
record.integral_freight_barcode = ''
|
||||
record.bar_freight_barcode = ''
|
||||
record.pad_freight_barcode_id = location.id
|
||||
record.integral_freight_barcode_id = False
|
||||
record.bar_freight_barcode_id = False
|
||||
else:
|
||||
raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
|
||||
else:
|
||||
@@ -490,6 +465,15 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
compute='_compute_after_assembly_max_lifetime_value')
|
||||
|
||||
obtain_measurement_status = fields.Boolean('是否获取测量值', default=False)
|
||||
enable_tool_presetter = fields.Boolean('是否启用刀具预调仪', default=lambda self: self.get_enable_tool_presetter())
|
||||
|
||||
def get_enable_tool_presetter(self):
|
||||
"""
|
||||
获取是否启用刀具预调仪数据
|
||||
"""
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
enable_tool_presetter = sf_sync_config['enable_tool_presetter']
|
||||
return enable_tool_presetter
|
||||
|
||||
@api.depends('after_assembly_tool_loading_length', 'after_assembly_handle_length')
|
||||
def _compute_after_assembly_functional_tool_length(self):
|
||||
@@ -553,32 +537,21 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
# functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False)
|
||||
# res_partner_id = fields.Many2one('res.partner', '智能工厂', domain="[('is_factory', '=', True)]")
|
||||
|
||||
@api.depends('after_assembly_functional_tool_type_id', 'integral_specification_id', 'bar_specification_id',
|
||||
'pad_specification_id', 'handle_specification_id', 'after_assembly_tool_loading_length')
|
||||
@api.depends('after_assembly_functional_tool_type_id', 'cutting_tool_cutterhandle_model_id',
|
||||
'after_assembly_functional_tool_diameter', 'after_assembly_tool_loading_length',
|
||||
'after_assembly_knife_tip_r_angle', 'after_assembly_functional_tool_length',
|
||||
'after_assembly_handle_length')
|
||||
def _compute_code(self):
|
||||
for obj in self:
|
||||
str_1 = 'GNDJ-%s' % obj.after_assembly_functional_tool_type_id.code
|
||||
str_2 = ''
|
||||
if obj.handle_specification_id:
|
||||
if obj.integral_specification_id:
|
||||
str_2 = '%s-D%sL%sB%sH%s-' % (
|
||||
str_1, obj.integral_specification_id.blade_diameter, obj.after_assembly_tool_loading_length,
|
||||
obj.integral_specification_id.blade_length, obj.handle_specification_id.total_length)
|
||||
elif obj.bar_specification_id:
|
||||
str_2 = '%s-D%sL%sB%sH%s-' % (
|
||||
str_1, obj.bar_specification_id.cutter_arbor_diameter, obj.after_assembly_tool_loading_length,
|
||||
obj.bar_specification_id.blade_length, obj.handle_specification_id.total_length)
|
||||
elif obj.pad_specification_id:
|
||||
str_2 = '%s-D%sL%sB%sH%s-' % (
|
||||
str_1, obj.pad_specification_id.cutter_head_diameter, obj.after_assembly_tool_loading_length,
|
||||
obj.pad_specification_id.cut_depth_max, obj.handle_specification_id.total_length,
|
||||
)
|
||||
else:
|
||||
obj.code = str_2
|
||||
return True
|
||||
obj.code = str_2 + str(self._get_code(str_2))
|
||||
if obj.cutting_tool_cutterhandle_model_id:
|
||||
code = obj.cutting_tool_cutterhandle_model_id.code.split('-', 1)[0]
|
||||
str_1 = '%s-GNDJ-%s-D%sL%sR%sB%sH%s' % (
|
||||
code, obj.after_assembly_functional_tool_type_id.code, obj.after_assembly_functional_tool_diameter,
|
||||
obj.after_assembly_tool_loading_length, obj.after_assembly_knife_tip_r_angle,
|
||||
round(obj.after_assembly_functional_tool_length, 3), obj.after_assembly_handle_length)
|
||||
obj.code = '%s-%s' % (str_1, self._get_code(str_1))
|
||||
else:
|
||||
obj.code = str_2
|
||||
obj.code = ''
|
||||
|
||||
def _get_code(self, str_2):
|
||||
functional_tool_assembly = self.env['sf.functional.cutting.tool.entity'].sudo().search(
|
||||
@@ -601,7 +574,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
else:
|
||||
obj.after_assembly_functional_tool_name = ''
|
||||
|
||||
@api.onchange('integral_freight_barcode')
|
||||
@api.onchange('integral_freight_barcode_id')
|
||||
def _onchange_after_assembly_functional_tool_diameter(self):
|
||||
for obj in self:
|
||||
if obj.integral_product_id:
|
||||
@@ -609,7 +582,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
else:
|
||||
obj.after_assembly_functional_tool_diameter = 0
|
||||
|
||||
@api.onchange('blade_freight_barcode')
|
||||
@api.onchange('blade_freight_barcode_id')
|
||||
def _onchange_after_assembly_knife_tip_r_angle(self):
|
||||
for obj in self:
|
||||
if obj.blade_product_id:
|
||||
@@ -644,25 +617,32 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
# 创建组装入库单
|
||||
# 创建功能刀具批次/序列号记录
|
||||
stock_lot = product_id.create_assemble_warehouse_receipt(self.id, functional_tool_assembly, self)
|
||||
# 封装功能刀具数据,用于更新组装单信息
|
||||
desc_1 = self.get_desc_1(stock_lot)
|
||||
# 封装功能刀具数据,用于创建功能刀具记录
|
||||
desc_2 = self.get_desc_2(stock_lot, functional_tool_assembly)
|
||||
# 创建刀具组装入库单
|
||||
self.env['stock.picking'].create_stocking_picking(stock_lot, functional_tool_assembly, self)
|
||||
# 刀具物料出库
|
||||
if self.handle_code_id:
|
||||
product_id.tool_material_stock_moves(self.handle_code_id, self.assembly_order_code)
|
||||
if self.integral_product_id:
|
||||
self.integral_product_id.material_stock_moves(self.integral_freight_barcode, self.assembly_order_code)
|
||||
self.integral_product_id.material_stock_moves(self.integral_freight_barcode_id,
|
||||
self.integral_freight_lot_id, self.assembly_order_code)
|
||||
if self.blade_product_id:
|
||||
self.blade_product_id.material_stock_moves(self.blade_freight_barcode, self.assembly_order_code)
|
||||
self.blade_product_id.material_stock_moves(self.blade_freight_barcode_id,
|
||||
self.blade_freight_lot_id, self.assembly_order_code)
|
||||
if self.bar_product_id:
|
||||
self.bar_product_id.material_stock_moves(self.bar_freight_barcode, self.assembly_order_code)
|
||||
self.bar_product_id.material_stock_moves(self.bar_freight_barcode_id,
|
||||
self.bar_freight_lot_id, self.assembly_order_code)
|
||||
if self.pad_product_id:
|
||||
self.pad_product_id.material_stock_moves(self.pad_freight_barcode, self.assembly_order_code)
|
||||
self.pad_product_id.material_stock_moves(self.pad_freight_barcode_id,
|
||||
self.pad_freight_lot_id, self.assembly_order_code)
|
||||
if self.chuck_product_id:
|
||||
self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode, self.assembly_order_code)
|
||||
self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode_id,
|
||||
self.chuck_freight_lot_id, self.assembly_order_code)
|
||||
|
||||
# ============================创建功能刀具列表、安全库存记录===============================
|
||||
# 封装功能刀具数据
|
||||
desc_2 = self.get_desc_2(stock_lot, functional_tool_assembly)
|
||||
# 创建功能刀具列表记录
|
||||
record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2)
|
||||
# 创建安全库存信息
|
||||
@@ -671,8 +651,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
}, record_1)
|
||||
|
||||
# =====================修改功能刀具组装单、机床换刀申请、CAM工单程序用刀计划的状态==============
|
||||
# 封装功能刀具数据
|
||||
desc_1 = self.get_desc_1(stock_lot)
|
||||
# 修改功能刀具组装单信息
|
||||
functional_tool_assembly.write(desc_1)
|
||||
if functional_tool_assembly.sf_machine_table_tool_changing_apply_id:
|
||||
@@ -729,12 +707,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
||||
'code': self.code,
|
||||
'rfid': self.rfid,
|
||||
'tool_groups_id': self.after_tool_groups_id.id,
|
||||
'integral_freight_barcode': self.integral_freight_barcode,
|
||||
'blade_freight_barcode': self.blade_freight_barcode,
|
||||
'bar_freight_barcode': self.bar_freight_barcode,
|
||||
'pad_freight_barcode': self.pad_freight_barcode,
|
||||
'handle_code_id': self.handle_code_id.id,
|
||||
'chuck_freight_barcode': self.chuck_freight_barcode,
|
||||
'integral_freight_barcode_id': self.integral_freight_barcode_id.id,
|
||||
'integral_lot_id': self.integral_freight_lot_id.lot_id.id,
|
||||
'blade_freight_barcode_id': self.blade_freight_barcode_id.id,
|
||||
'blade_lot_id': self.blade_freight_lot_id.lot_id.id,
|
||||
'bar_freight_barcode_id': self.bar_freight_barcode_id.id,
|
||||
'bar_lot_id': self.bar_freight_lot_id.lot_id.id,
|
||||
'pad_freight_barcode_id': self.pad_freight_barcode_id.id,
|
||||
'pad_lot_id': self.pad_freight_lot_id.lot_id.id,
|
||||
'chuck_freight_barcode_id': self.chuck_freight_barcode_id.id,
|
||||
'chuck_lot_id': self.chuck_freight_lot_id.lot_id.id,
|
||||
|
||||
'after_assembly_functional_tool_name': self.after_assembly_functional_tool_name,
|
||||
'after_assembly_functional_tool_type_id': self.after_assembly_functional_tool_type_id.id,
|
||||
@@ -815,6 +798,7 @@ class StockPicking(models.Model):
|
||||
'picking_type_id': picking_type_id.id,
|
||||
'location_id': picking_type_id.default_location_src_id.id,
|
||||
'location_dest_id': picking_type_id.default_location_dest_id.id,
|
||||
'origin': obj.assembly_order_code
|
||||
})
|
||||
# 创建作业详情对象记录,并绑定到刀具组装入库单
|
||||
self.env['stock.move.line'].create({
|
||||
@@ -865,7 +849,7 @@ class ProductProduct(models.Model):
|
||||
logging.info('没有搜索到功能刀具产品:%s' % product_id)
|
||||
raise ValidationError('没有找到按唯一序列号追溯的功能刀具产品信息!')
|
||||
stock_lot = self.env['stock.lot'].create({
|
||||
'name': self.get_stock_lot_name(tool_assembly_order_id),
|
||||
'name': self.get_stock_lot_name(obj),
|
||||
'product_id': product_id[0].id,
|
||||
'company_id': self.env.company.id
|
||||
})
|
||||
@@ -878,25 +862,21 @@ class ProductProduct(models.Model):
|
||||
|
||||
return stock_lot
|
||||
|
||||
def get_stock_lot_name(self, tool_assembly_order_id):
|
||||
def get_stock_lot_name(self, obj):
|
||||
"""
|
||||
生成功能刀具序列号
|
||||
"""
|
||||
tool_assembly_order = self.env['sf.functional.tool.assembly.order'].search(
|
||||
[('id', '=', tool_assembly_order_id)])
|
||||
code = 'JKM-T-' + str(tool_assembly_order.after_assembly_functional_tool_type_id.code) + '-' + str(
|
||||
tool_assembly_order.after_assembly_functional_tool_diameter) + '-'
|
||||
company = obj.cutting_tool_cutterhandle_model_id.code.split('-', 1)[0]
|
||||
new_time = datetime.strptime(str(fields.Date.today()), "%Y-%m-%d").strftime("%Y%m%d")
|
||||
code += str(new_time) + '-'
|
||||
code = '%s-GNDJ-%s-%s' % (company, obj.after_assembly_functional_tool_type_id.code, new_time)
|
||||
stock_lot_id = self.env['stock.lot'].sudo().search(
|
||||
[('name', 'like', new_time), ('product_id.categ_type', '=', '功能刀具'),
|
||||
('product_id.tracking', '=', 'serial')], limit=1, order="id desc")
|
||||
[('name', 'like', code)], limit=1, order="id desc")
|
||||
if not stock_lot_id:
|
||||
num = "%03d" % 1
|
||||
else:
|
||||
m = int(stock_lot_id.name[-3:]) + 1
|
||||
num = "%03d" % m
|
||||
return code + str(num)
|
||||
return '%s-%s' % (code, num)
|
||||
|
||||
def tool_material_stock_moves(self, tool_material, assembly_order_code):
|
||||
"""
|
||||
@@ -909,7 +889,7 @@ class ProductProduct(models.Model):
|
||||
tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, assembly_order_code, False,
|
||||
False)
|
||||
|
||||
def material_stock_moves(self, shelf_location_barcode, assembly_order_code):
|
||||
def material_stock_moves(self, shelf_location_barcode_id, lot_id, assembly_order_code):
|
||||
# 创建库存移动记录
|
||||
stock_move_id = self.env['stock.move'].sudo().create({
|
||||
'name': assembly_order_code,
|
||||
@@ -920,21 +900,16 @@ class ProductProduct(models.Model):
|
||||
'state': 'done'
|
||||
})
|
||||
|
||||
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', shelf_location_barcode)])
|
||||
# 创建移动历史记录
|
||||
stock_move_line_id = self.env['stock.move.line'].sudo().create({
|
||||
'product_id': self.id,
|
||||
'move_id': stock_move_id.id,
|
||||
'current_location_id': location.id,
|
||||
'lot_id': lot_id.lot_id.id,
|
||||
'current_location_id': shelf_location_barcode_id.id,
|
||||
'install_tool_time': fields.Datetime.now(),
|
||||
'qty_done': 1.0,
|
||||
'state': 'done',
|
||||
})
|
||||
if location.product_num > 0:
|
||||
location.product_num = location.product_num - 1
|
||||
else:
|
||||
raise ValidationError(
|
||||
'【%s】货位的【%s】产品库存数量为零,请采购入库后再重新组装!' % (location.barcode, location.product_id.name))
|
||||
return stock_move_id, stock_move_line_id
|
||||
|
||||
|
||||
|
||||
@@ -229,13 +229,18 @@
|
||||
</group>
|
||||
</group>
|
||||
<group col="1"
|
||||
attrs="{'invisible': ['|','|',('blade_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False),('pad_freight_barcode', '!=', False)]}">
|
||||
attrs="{'invisible': ['|','|',('blade_freight_barcode_id', '!=', False),('bar_freight_barcode_id', '!=', False),('pad_freight_barcode_id', '!=', False)]}">
|
||||
<div>
|
||||
<separator string="整体式刀具:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="integral_freight_barcode" string="货位"/>
|
||||
<field name="integral_freight_barcode_id" options="{'no_create': True}"
|
||||
placeholder="请选择" string="货位"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="integral_freight_lot_id" options="{'no_create': True}"
|
||||
placeholder="请选择" string="批次"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="2">
|
||||
@@ -249,13 +254,18 @@
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<group col="1" attrs="{'invisible': [('integral_freight_barcode', '!=', False)]}">
|
||||
<group col="1" attrs="{'invisible': [('integral_freight_barcode_id', '!=', False)]}">
|
||||
<div>
|
||||
<separator string="刀片:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="blade_freight_barcode" string="货位"/>
|
||||
<field name="blade_freight_barcode_id" options="{'no_create': True}"
|
||||
placeholder="请选择" string="货位"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="blade_freight_lot_id" options="{'no_create': True}"
|
||||
placeholder="请选择" string="批次"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="2">
|
||||
@@ -270,13 +280,18 @@
|
||||
</group>
|
||||
</group>
|
||||
<group col="1"
|
||||
attrs="{'invisible': ['|',('integral_freight_barcode', '!=', False),('pad_freight_barcode', '!=', False)]}">
|
||||
attrs="{'invisible': ['|',('integral_freight_barcode_id', '!=', False),('pad_freight_barcode_id', '!=', False)]}">
|
||||
<div>
|
||||
<separator string="刀杆:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="bar_freight_barcode" string="货位"/>
|
||||
<field name="bar_freight_barcode_id" options="{'no_create': True}"
|
||||
placeholder="请选择" string="货位"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="bar_freight_lot_id" options="{'no_create': True}" placeholder="请选择"
|
||||
string="批次"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="2">
|
||||
@@ -291,13 +306,18 @@
|
||||
</group>
|
||||
</group>
|
||||
<group col="1"
|
||||
attrs="{'invisible': ['|',('integral_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False)]}">
|
||||
attrs="{'invisible': ['|',('integral_freight_barcode_id', '!=', False),('bar_freight_barcode_id', '!=', False)]}">
|
||||
<div>
|
||||
<separator string="刀盘:" style="font-size: 13px;"/>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="pad_freight_barcode" string="货位"/>
|
||||
<field name="pad_freight_barcode_id" options="{'no_create': True}"
|
||||
placeholder="请选择" string="货位"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="pad_freight_lot_id" options="{'no_create': True}" placeholder="请选择"
|
||||
string="批次"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="2">
|
||||
@@ -317,7 +337,12 @@
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="chuck_freight_barcode" string="货位"/>
|
||||
<field name="chuck_freight_barcode_id" options="{'no_create': True}"
|
||||
placeholder="请选择" string="货位"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="chuck_freight_lot_id" options="{'no_create': True}"
|
||||
placeholder="请选择" string="批次"/>
|
||||
</group>
|
||||
</group>
|
||||
<group col="2">
|
||||
@@ -343,12 +368,14 @@
|
||||
<group>
|
||||
<field name="obtain_measurement_status" invisible="1"/>
|
||||
<button name="get_tool_preset_parameter" string="获取测量值" type="object"
|
||||
attrs="{'invisible': [('enable_tool_presetter', '=', False)]}"
|
||||
class="btn-primary"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group>
|
||||
<field name="after_name_id" string="功能刀具名称" placeholder="请选择功能刀具名称" readonly="1"
|
||||
<field name="after_name_id" string="功能刀具名称" placeholder="请选择功能刀具名称"
|
||||
readonly="1"
|
||||
options="{'no_create': True, 'no_quick_create': True}"/>
|
||||
<field name="after_assembly_functional_tool_name" string="功能刀具名称"
|
||||
invisible="1"/>
|
||||
@@ -367,12 +394,16 @@
|
||||
attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="enable_tool_presetter" invisible="1"/>
|
||||
<field name="after_assembly_functional_tool_diameter" string="刀具直径(mm)"
|
||||
class="custom_required" readonly="1"/>
|
||||
attrs="{'readonly': [('enable_tool_presetter', '=', True)]}"
|
||||
class="custom_required"/>
|
||||
<field name="after_assembly_knife_tip_r_angle" string="刀尖R角(mm)"
|
||||
class="custom_required" readonly="1"/>
|
||||
attrs="{'readonly': [('enable_tool_presetter', '=', True)]}"
|
||||
class="custom_required"/>
|
||||
<field name="after_assembly_tool_loading_length" string="总长度(mm)"
|
||||
class="custom_required" readonly="1"/>
|
||||
attrs="{'readonly': [('enable_tool_presetter', '=', True)]}"
|
||||
class="custom_required"/>
|
||||
<field name="after_assembly_handle_length" string="刀柄长度(mm)"
|
||||
class="custom_required"/>
|
||||
<field name="after_assembly_functional_tool_length" string="伸出长(mm)"
|
||||
@@ -392,7 +423,7 @@
|
||||
</sheet>
|
||||
<footer>
|
||||
<button string="确定" name="functional_tool_assembly" type="object" class="btn-primary"
|
||||
attrs="{'invisible': [('obtain_measurement_status', '=', False)]}"
|
||||
attrs="{'invisible': [('obtain_measurement_status', '=', False),('enable_tool_presetter', '=', True)]}"
|
||||
confirm="是否确认申请组装"/>
|
||||
<button string="取消" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
|
||||
Reference in New Issue
Block a user