Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造功能优化

# Conflicts:
#	sf_manufacturing/models/mrp_production.py
This commit is contained in:
mgw
2025-01-13 16:56:49 +08:00
7 changed files with 51 additions and 23 deletions

View File

@@ -140,7 +140,4 @@
</field>
</record>
<record id="quality_control.quality_check_action_main" model="ir.actions.act_window">
<field name="context">{'search_default_quality_checks': 1}</field>
</record>
</odoo>

View File

@@ -433,7 +433,6 @@ class MrpProduction(models.Model):
# 工艺确认
def technology_confirm(self):
process_parameters = []
account_moves = []
purchase_orders = []
parameters_not = []
# 获取原有的工单对应的工序
@@ -464,6 +463,7 @@ class MrpProduction(models.Model):
if account_moves:
raise UserError(_("请联系工厂生产经理对该(%s)账单进行取消", ", ".join(account_moves)))
if purchase_orders:
raise UserError(_("请联系工厂生产经理对该(%s)采购订单进行取消", ", ".join(purchase_orders)))
if parameters_not:
@@ -1543,22 +1543,26 @@ class MrpProduction(models.Model):
picking_type_id = self._get_default_picking_type_id(vals.get('company_id', self.env.company.id))
vals['picking_type_id'] = picking_type_id
vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id()
if not is_first:
product_id = self.env['product.product'].browse(vals['product_id'])
is_self_process = product_id.materials_type_id and product_id.materials_type_id.gain_way and product_id.materials_type_id.gain_way != '自加工'
if not is_first and is_self_process:
is_first = True
group_id = self.env["procurement.group"].create({'name': vals.get('name')}).id
if not vals.get('procurement_group_id'):
product_id = self.env['product.product'].browse(vals['product_id'])
if product_id.product_tmpl_id.single_manufacturing:
if product_id.categ_id.name == '成品':
if product_id.categ_id.name == '成品' and is_self_process:
vals['procurement_group_id'] = group_id
continue
if product_id.id not in product_group_id.keys():
procurement_group_vals = self._prepare_procurement_group_vals(vals)
group_id = self.env["procurement.group"].create(procurement_group_vals).id
vals['procurement_group_id'] = group_id
product_group_id[product_id.id] = group_id
procurement_group_id = self.env["procurement.group"].create(procurement_group_vals).id
vals['procurement_group_id'] = procurement_group_id
product_group_id[product_id.id] = procurement_group_id
else:
vals['procurement_group_id'] = product_group_id[product_id.id]
else:
vals['procurement_group_id'] = group_id
return super(MrpProduction, self).create(vals_list)
@@ -1729,7 +1733,12 @@ class sf_detection_result(models.Model):
processing_panel = fields.Char('加工面')
routing_type = fields.Selection([
('装夹预调', '装夹预调'),
('CNC加工', 'CNC加工')], string="工序类型")
('CNC加工', 'CNC加工'),
('解除装夹', '解除装夹'),
('切割', '切割'),
('表面工艺', '表面工艺'),
('线切割', '线切割'),
('人工线下加工', '人工线下加工')], string="工序类型")
rework_reason = fields.Selection(
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),

View File

@@ -1267,7 +1267,7 @@ class ResMrpWorkOrder(models.Model):
record.production_id.process_state = '待加工'
# 生成工件配送单
record.workpiece_delivery_ids = record._json_workpiece_delivery_list()
if record.routing_type == 'CNC加工':
if record.routing_type == 'CNC加工' or record.individuation_page_PTD is True:
record.process_state = '待解除装夹'
# record.write({'process_state': '待加工'})
record.production_id.process_state = '待解除装夹'
@@ -1358,17 +1358,18 @@ class ResMrpWorkOrder(models.Model):
# record.production_id.state = 'done'
# ============工单完成,修改对应[质检单]的值=====================
if record.check_ids:
if record.check_ids.filtered(lambda qc: qc.quality_state in ('waiting', 'none')):
check_ids = record.check_ids.filtered(lambda qc: qc.quality_state in ('waiting', 'none'))
if record.test_results == '合格':
record.check_ids.write({'test_results': None})
for check_id in record.check_ids:
check_ids.write({'test_results': None})
for check_id in check_ids:
check_id.do_pass()
elif record.test_results in ('返工', '报废'):
record.check_ids.write({
check_ids.write({
'test_results': record.test_results,
'reason': record.reason,
'detailed_reason': record.detailed_reason})
for check_id in record.check_ids:
for check_id in check_ids:
check_id.do_fail()
# ======================================================

View File

@@ -4,6 +4,7 @@
from collections import defaultdict
from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.tools import OrderedSet
@@ -16,6 +17,20 @@ class PurchaseOrder(models.Model):
compute='_compute_workorder_count',
)
def button_cancel(self):
account_moves = set() # 使用集合以避免重复,并提高查找速度
accounts = self.env['account.move'].search(
[('id', 'in', self.invoice_ids.ids), ('state', 'not in', ['cancel', False])])
# 直接筛选掉状态为'cancel'或False的记录避免多次迭代
for account in accounts:
account_moves.add(account.name) # 使用set的add方法避免重复添加
# 如果你需要list形式的结果可以将set转换为list
account_moves = list(account_moves)
if account_moves:
raise UserError(_("请联系工厂生产经理对该采购单的账单进行取消"))
return super(PurchaseOrder, self).button_cancel()
def action_view_production(self):
origins = [order.name for order in self.picking_ids]
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])

View File

@@ -187,7 +187,7 @@
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}"/>
<button name="do_inspect" type="object" string="送检" class="btn-success" confirm="是否确认送检"
attrs="{'invisible': ['|', '|', ('production_state', 'not in', ('progress')), ('is_inspect', '=', False), ('routing_type','=','CNC加工')]}"/>
attrs="{'invisible': ['|', '|', ('state', 'not in', ('progress')), ('is_inspect', '=', False), ('routing_type','=','CNC加工')]}"/>
<!-- <button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="停工" -->
<!-- context="{'default_workcenter_id': workcenter_id}" class="btn-danger" -->
@@ -529,7 +529,8 @@
<page string="后置三元检测" attrs='{"invisible": [("individuation_page_PTD", "=", False)]}'>
<group>
<field name="test_results"
attrs='{"readonly":[("state","!=","to be detected")],"invisible":[("results","!=",False)]}'/>
attrs='{"readonly":[("state","!=","to be detected"), "|",("routing_type","=","CNC加工"),("is_inspect", "=", True)],
"invisible":[("results","!=",False)]}'/>
<!-- <field name="is_remanufacture" attrs='{"invisible":[("test_results","!=","报废")]}'/>-->
<!-- <field name="is_fetchcnc"-->
<!-- attrs='{"invisible":["|",("test_results","=","合格"),("is_remanufacture","=",False)]}'/>-->

View File

@@ -25,9 +25,9 @@
<!-- 添加销售订单号字段-->
<xpath expr="//sheet/group/group[2]/div[@name='date_approve']" position="after">
<field name="origin_sale_id" readonly="1" string="参考销售订单"
attrs="{'invisible': [('origin_sale_id' , '=', False)]}"/>
attrs="{'invisible': [('origin_sale_ids' , '!=', False)]}"/>
<field name="origin_sale_ids" readonly="1" string="参考销售订单" widget="many2many_tags"
attrs="{'invisible': [('origin_sale_ids' , '=', [])]}"/>
attrs="{'invisible': [('origin_sale_ids' , '=', False)]}"/>
</xpath>
</field>
</record>

View File

@@ -24,7 +24,12 @@ class ReworkWizard(models.TransientModel):
detailed_reason = fields.Text('详细原因')
routing_type = fields.Selection([
('装夹预调', '装夹预调'),
('CNC加工', 'CNC加工')], string="工序类型")
('CNC加工', 'CNC加工'),
('解除装夹', '解除装夹'),
('切割', '切割'),
('表面工艺', '表面工艺'),
('线切割', '线切割'),
('人工线下加工', '人工线下加工')], string="工序类型")
# 根据工单的加工面来显示
processing_panel_id = fields.Many2many('sf.processing.panel', string="加工面")
is_reprogramming = fields.Boolean(string='申请重新编程', default=False)