验证坯料序列号

This commit is contained in:
gqh
2023-02-24 17:23:00 +08:00
parent 7ddaace1ad
commit 4ec5f2c1de
2 changed files with 33 additions and 5 deletions

View File

@@ -202,10 +202,24 @@ class ResMrpWorkOrder(models.Model):
else:
raise UserError('托盘码不能为空')
#验证坯料序列号是否正确
def pro_code_is_ok(self,barcode):
if barcode!=False:
if barcode != self.pro_code:
raise UserError('坯料序列号错误')
return False
else:
return True
pro_code = fields.Char(string='坯料序列号')
pro_code_ok = fields.Boolean(default=False)
#托盘扫码绑定
def gettray_auto(self, barcode):
if barcode != False:
values = self.env['sf.tray'].search([("code", "=", barcode)])
if values:
if values.state == "占用":
raise UserError('该托盘已占用')
@@ -378,8 +392,11 @@ class ResMrpWorkOrder(models.Model):
}]
return workorders_values_str
# 重写工单开始按钮方法
def button_start(self):
if self.routing_type == '装夹':
self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name
if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress':
self.ensure_one()
if any(not time.date_end for time in self.time_ids.filtered(lambda t: t.user_id.id == self.env.user.id)):
@@ -538,10 +555,15 @@ class SfWorkOrderBarcodes(models.Model):
_inherit = ["mrp.workorder", "barcodes.barcode_events_mixin"]
def on_barcode_scanned(self, barcode):
tray_code = self.env['sf.tray'].search([('code', '=', barcode)])
self.tray_code = tray_code.code
workorder = self.env['mrp.workorder'].browse(self.ids)
self.tray_id = workorder.gettray_auto(barcode)
if "*" not in barcode:
tray_code = self.env['sf.tray'].search([('code', '=', barcode)])
self.tray_code = tray_code.code
self.tray_id = workorder.gettray_auto(barcode)
else:
self.pro_code_ok = workorder.pro_code_is_ok(barcode)
# return {
# 'type': 'ir.actions.act_window',

View File

@@ -166,9 +166,15 @@
<field name="routing_type" invisible="1"/>
<field name="tray_code"/>
<field name="tray_id" readonly="1"/>
</group>
<group>
<field name="pro_code" readonly="1" attrs='{"invisible": [("pro_code_ok","=",False)]}' style="color:green"/>
<field name="pro_code" readonly="1" attrs='{"invisible": [("pro_code_ok","!=",False)]}'/>
<div>
<field name="pro_code_ok" invisible="1"/>
</div>
</group>
<div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="gettray" string="绑定托盘"
attrs='{"invisible": ["|","|",("tray_id","!=",False),("state","!=","progress"),("production_id","=",False)]}'/>