Merge branch 'feature/工单rfid优化' into feature/制造、采购、工单优化

This commit is contained in:
yuxianghui
2024-12-23 13:47:22 +08:00
7 changed files with 42 additions and 20 deletions

View File

@@ -36,6 +36,8 @@ class StatusChange(models.Model):
# 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法)
try:
res = super(StatusChange, self).action_confirm()
# 修改销售订单状态为【加工中】
self.write({'state': 'processing'})
logging.info('原生方法返回结果:%s' % res)
# 原有方法执行后进行额外的操作如调用外部API
process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')

View File

@@ -963,10 +963,11 @@ class MrpProduction(models.Model):
work_ids = workorder_ids.filtered(lambda item: item.sequence == 0)
# 对工单进行逐个插入
for work_id in work_ids:
for order_id in rec.workorder_ids.filtered(lambda item: item.sequence > 0):
if work_id.name == order_id.name and work_id.processing_panel == order_id.processing_panel:
work_id.sequence = order_id.sequence + 1
break
order_rework_ids = rec.workorder_ids.filtered(
lambda item: (item.sequence > 0 and work_id.name == item.name
and work_id.processing_panel == item.processing_panel))
order_rework_ids = sorted(order_rework_ids, key=lambda item: item.sequence, reverse=True)
work_id.sequence = order_rework_ids[0].sequence + 1
# 对该工单之后的工单工序进行加一
work_order_ids = rec.workorder_ids.filtered(
lambda item: item.sequence >= work_id.sequence and item.id != work_id.id)

View File

@@ -138,7 +138,8 @@ class ResMrpWorkOrder(models.Model):
is_subcontract = fields.Boolean(string='是否外协')
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
picking_ids = fields.Many2many('stock.picking', string='外协出入库单', compute='_compute_surface_technics_picking_ids')
picking_ids = fields.Many2many('stock.picking', string='外协出入库单',
compute='_compute_surface_technics_picking_ids')
purchase_id = fields.Many2many('purchase.order', string='外协采购单')
surface_technics_picking_count = fields.Integer("外协出入库", compute='_compute_surface_technics_picking_ids')
@@ -327,7 +328,7 @@ class ResMrpWorkOrder(models.Model):
'view_mode': 'form',
}
return result
def _get_surface_technics_purchase_ids(self):
domain = [('origin', '=', self.production_id.name), ('purchase_type', '=', 'consignment')]
purchase_orders = self.env['purchase.order'].search(domain)
@@ -1429,6 +1430,8 @@ class ResMrpWorkOrder(models.Model):
rfid_code = workorder.rfid_code
workorder.write({'rfid_code_old': rfid_code,
'rfid_code': False})
self.env['stock.lot'].sudo().search([('rfid', '=', rfid_code)]).write(
{'tool_material_status': '可用'})
if workorder.rfid_code:
raise ValidationError(f'{workorder.name}】工单解绑失败,请重新点击完成按钮!!!')
# workorder.rfid_code_old = rfid_code
@@ -1567,7 +1570,7 @@ class ResMrpWorkOrder(models.Model):
'default_confirm_button': '确认解除',
# 'default_feeder_station_start_id': feeder_station_start_id,
}}
move_subcontract_workorder_ids = fields.One2many('stock.move', 'subcontract_workorder_id', string='组件')
@@ -1778,6 +1781,7 @@ class SfWorkOrderBarcodes(models.Model):
if workorder_rfid:
for item in workorder_rfid:
item.write({'rfid_code': barcode})
lot.sudo().write({'tool_material_status': '在用'})
logging.info("Rfid[%s]绑定成功!!!" % barcode)
else:
raise UserError('该Rfid【%s】绑定的是【%s】, 不是托盘!!!' % (barcode, lot.product_id.name))

View File

@@ -444,9 +444,7 @@
<xpath expr="//tree//button[@name='button_start']" position="replace">
<field name="routing_type" invisible="True"/>
<button name="button_start" type="object" string="开始" class="btn-success" confirm="是否确认开始?"
attrs="{'invisible': ['|', '|', '|','|', ('production_state','in', ('draft', 'done', 'cancel')),
('working_state', '=', 'blocked'), ('state', 'in', ('done','rework', 'cancel')), ('is_user_working', '!=',
False), ('routing_type', '=', 'CNC加工')]}"
attrs="{'invisible': [('state', '!=', 'ready')]}"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='button_pending']" position="replace">

View File

@@ -55,10 +55,7 @@
<!-- 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')),-->
<!-- ('is_user_working', '!=', False),("user_permissions","=",False),("name","=","CNC加工")]}-->
<!-- </attribute>-->
<attribute name="attrs">{'invisible': ['|', '|', '|','|','|', ('production_state','in', ('draft',
'done',
'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done','rework', 'cancel')),
('is_user_working', '!=', False),("user_permissions","=",False),("name","in",("CNC加工","解除装夹"))]}
<attribute name="attrs">{'invisible': [('state', '!=', 'ready')]}
</attribute>
</xpath>
<xpath expr="//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="attributes">
@@ -176,9 +173,9 @@
<!-- <button name="button_start" type="object" string="开始" class="btn-success" confirm="是否确认开始"-->
<!-- attrs="{'invisible': ['|', '|', '|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel','to be detected')), ('is_user_working', '!=', False)]}"/>-->
<button name="button_start" type="object" string="开始" class="btn-success" confirm="是否确认开始"
attrs="{'invisible': ['|', '|', '|', '|', '|', ('routing_type', '=', '装夹预调'), ('routing_type', '=', '解除装夹'), ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done','rework', 'cancel','to be detected')), ('is_user_working', '!=', False)]}"/>
attrs="{'invisible': [('state', '!=', 'ready')]}"/>
<button name="button_start" type="object" string="开始" class="btn-success"
attrs="{'invisible': ['|', '|', '|', '|', ('routing_type', '!=', '装夹预调'), ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done','rework', 'cancel','to be detected')), ('is_user_working', '!=', False)]}"/>
attrs="{'invisible': [('state', '!=', 'ready')]}"/>
<button name="button_pending" type="object" string="暂停" class="btn-warning"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>
<button name="button_finish" type="object" string="完成" class="btn-success" confirm="是否确认完工"

View File

@@ -283,12 +283,28 @@ class RePurchaseOrder(models.Model):
purchase_type = fields.Selection(
[('standard', '标准采购'), ('consignment', '委外加工'), ('outsourcing', '工序外协'), ('outside', '外购订单')],
string='采购类型', default='standard')
string='采购类型', default='standard', store=True, compute='_compute_purchase_type')
origin_sale_id = fields.Many2one('sale.order', string='销售订单号', compute='_compute_origin_sale_id')
@api.depends('origin')
def _compute_purchase_type(self):
for purchase in self:
order_id = self.env['sale.order'].sudo().search([('name', '=', purchase.origin)])
if order_id:
product_list = [line.product_id.id for line in purchase.order_line]
for order_line in order_id.order_line:
if order_line.supply_method == 'purchase':
if order_line.product_id.id in product_list:
purchase.purchase_type = 'outside'
break
elif order_line.supply_method == 'outsourcing':
if order_line.product_id.id in product_list:
purchase.purchase_type = 'consignment'
break
@api.depends('order_line.move_dest_ids.group_id.mrp_production_ids',
'order_line.move_ids.move_dest_ids.group_id.mrp_production_ids')
'order_line.move_ids.move_dest_ids.group_id.mrp_production_ids', 'origin')
def _compute_origin_sale_id(self):
for purchase in self:
productions_ids = purchase._get_mrp_productions()
@@ -296,6 +312,10 @@ class RePurchaseOrder(models.Model):
if productions_ids[0].sale_order_id:
purchase.origin_sale_id = productions_ids[0].sale_order_id.id
continue
order_id = self.env['sale.order'].sudo().search([('name', '=', purchase.origin)])
if order_id:
purchase.origin_sale_id = order_id.id
continue
purchase.origin_sale_id = False
@api.depends('partner_id')
@@ -345,7 +365,7 @@ class RePurchaseOrder(models.Model):
'partner_id': server_template.seller_ids[0].partner_id.id,
'origin': production.name,
'state': 'draft',
'purchase_type': 'consignment',
'purchase_type': 'outsourcing',
'order_line': server_product_process})
pp.purchase_id = [(6, 0, [purchase_order.id])]
# self.env.cr.commit()

View File

@@ -126,7 +126,7 @@ class StockLot(models.Model):
tool_material_search_id = fields.Many2one('sf.tool.material.search', string='刀具物料搜索')
fixture_material_search_id = fields.Many2one('sf.fixture.material.search', string='夹具物料搜索')
tool_material_status = fields.Selection(
[('未入库', '未入库'), ('可用', '可用'), ('在用', '在用'), ('报废', '报废')], string='状态',
[('未入库', '未入库'), ('可用', '可用'), ('在用', '空闲'), ('报废', '报废')], string='状态',
compute='_compute_tool_material_status', store=True)
@api.depends('quant_ids')