1、组装单添加校验
This commit is contained in:
@@ -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)
|
||||
@@ -668,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):
|
||||
@@ -758,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)
|
||||
@@ -766,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)
|
||||
|
||||
# 刀柄
|
||||
@@ -778,7 +780,7 @@ class FunctionalToolDismantle(models.Model):
|
||||
handle_rfid = fields.Char(string='刀柄Rfid', compute='_compute_functional_tool_num', store=True)
|
||||
handle_lot_id = fields.Many2one('stock.lot', string='刀柄序列号', compute='_compute_functional_tool_num',
|
||||
store=True)
|
||||
scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False)
|
||||
scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False, tracking=True)
|
||||
|
||||
# 整体式
|
||||
integral_product_id = fields.Many2one('product.product', string='整体式刀具',
|
||||
@@ -888,6 +890,27 @@ class FunctionalToolDismantle(models.Model):
|
||||
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
|
||||
@@ -897,6 +920,8 @@ class FunctionalToolDismantle(models.Model):
|
||||
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', '=', '刀具房')])
|
||||
# =================刀柄是否[报废]拆解=======
|
||||
@@ -908,11 +933,11 @@ 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 ['寿命到期报废', '崩刀报废']:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
@@ -674,6 +680,10 @@
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids"/>
|
||||
<field name="message_ids"/>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -817,8 +827,7 @@
|
||||
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="批次"
|
||||
attrs="{'required': [('chuck_product_id', '!=', False)]}"/>
|
||||
<field name="chuck_lot_id" string="批次"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
@@ -834,8 +843,7 @@
|
||||
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="批次"
|
||||
attrs="{'required': [('integral_product_id', '!=', False)]}"/>
|
||||
<field name="integral_lot_id" string="批次"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
@@ -851,8 +859,7 @@
|
||||
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="批次"
|
||||
attrs="{'required': [('blade_product_id', '!=', False)]}"/>
|
||||
<field name="blade_lot_id" string="批次"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="刀杆" attrs="{'invisible': [('bar_product_id', '=', False)]}">
|
||||
@@ -866,8 +873,7 @@
|
||||
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="批次"
|
||||
attrs="{'required': [('bar_product_id', '!=', False)]}"/>
|
||||
<field name="bar_lot_id" string="批次"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="刀盘" attrs="{'invisible': [('pad_product_id', '=', False)]}">
|
||||
@@ -881,14 +887,27 @@
|
||||
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="批次"
|
||||
attrs="{'required': [('pad_product_id', '!=', False)]}"/>
|
||||
<field name="pad_lot_id" string="批次"/>
|
||||
</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>
|
||||
|
||||
@@ -775,6 +775,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({
|
||||
|
||||
Reference in New Issue
Block a user