Accept Merge Request #143: (feature/sf胚料序号码验证 -> develop)

Merge Request: 坯料认证判断

Created By: @龚启豪
Accepted By: @龚启豪
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/143?initial=true
This commit is contained in:
龚启豪
2023-02-27 09:44:51 +08:00
7 changed files with 44 additions and 13 deletions

View File

@@ -13,8 +13,8 @@
'depends': ['sf_base', 'sf_sale', 'sf_dlm'],
'data': [
'views/res_partner_view.xml',
'views/view.xml',
'report/bill_report.xml',
# 'views/view.xml',
# 'report/bill_report.xml',
],
'demo': [
],

View File

@@ -1,5 +1,5 @@
from . import http
from . import models
from . import process_status
from . import jd_eclp
# from . import jd_eclp

View File

@@ -115,7 +115,7 @@ class FinishStatusChange(models.Model):
# default_code = fields.Char(string='内部编码')
def button_validate(self):
def button_validate1(self):
# Clean-up the context key at validation to avoid forcing the creation of immediate
# transfers.
ctx = dict(self.env.context)

View File

@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
import re
from odoo import api, fields, models, _
@@ -57,11 +59,12 @@ class MrpProduction(models.Model):
def action_generate_serial(self):
self.ensure_one()
iot_code = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id) or self.env['ir.sequence'].next_by_code('stock.lot.serial')
iot_code_name = re.sub('[\u4e00-\u9fa5]', "", iot_code)
self.lot_producing_id = self.env['stock.lot'].create({
'product_id': self.product_id.id,
'company_id': self.company_id.id,
'name': self.env['stock.lot']._get_next_serial(self.company_id, self.product_id) or self.env[
'ir.sequence'].next_by_code('stock.lot.serial'),
'name': iot_code_name,
})
if self.move_finished_ids.filtered(lambda m: m.product_id == self.product_id).move_line_ids:
self.move_finished_ids.filtered(
@@ -235,6 +238,7 @@ class MrpProduction(models.Model):
current_sequence += 1
if work.name == '获取CNC加工程序':
work.button_start()
#work.button_finish()
work.fetchCNC()
#创建工单并进行排序

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)]}'/>

View File

@@ -15,8 +15,7 @@
attrs='{"invisible": [("production_id","=",False)]}'/>
<field name="workorder_id"/>
</group>
<div class="col
-12 col-lg-6 o_setting_box">
<div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="unclamp" string="解除装夹"
attrs='{"invisible": [("state","=","空闲")]}'/>
</div>