Compare commits
61 Commits
feature/加工
...
feature/取消
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e27ee2434 | ||
|
|
5dc5602e3d | ||
|
|
e20bf3816a | ||
|
|
44f29d001e | ||
|
|
aff81f0b3a | ||
|
|
88840abf9f | ||
|
|
332276752a | ||
|
|
d852cf54df | ||
|
|
6756cc201c | ||
|
|
06dd9c12e0 | ||
|
|
978e427734 | ||
|
|
dd35a6ae5f | ||
|
|
0a8cc050b8 | ||
|
|
eb47e4c963 | ||
|
|
5636681ee6 | ||
|
|
9b49edb290 | ||
|
|
39b29960e3 | ||
|
|
6abb237491 | ||
|
|
b0c043676c | ||
|
|
8f9b7b2fb0 | ||
|
|
32255af3a3 | ||
|
|
955b6a6213 | ||
|
|
8e788d3745 | ||
|
|
dc843588e9 | ||
|
|
8bfe5eca03 | ||
|
|
dbcf8b1089 | ||
|
|
0bf701e743 | ||
|
|
a96a9f5b75 | ||
|
|
9e2704f726 | ||
|
|
c436bbea46 | ||
|
|
47c73ae66e | ||
|
|
53ceed4649 | ||
|
|
e39e9d8812 | ||
|
|
0a01afc863 | ||
|
|
98b338f33a | ||
|
|
3c12b05b94 | ||
|
|
b619c15231 | ||
|
|
bccdd93884 | ||
|
|
41cdeb7fd9 | ||
|
|
57ab276c37 | ||
|
|
f3e64b007e | ||
|
|
eed89836e1 | ||
|
|
19e1b16122 | ||
|
|
9efa4636d9 | ||
|
|
0b2b9c2bf5 | ||
|
|
cc5036ce64 | ||
|
|
2dc54792f4 | ||
|
|
5db877a54c | ||
|
|
6bff1f2f64 | ||
|
|
0aaa3bd5ba | ||
|
|
39d6c8ae24 | ||
|
|
2c56011502 | ||
|
|
1e71fc1b08 | ||
|
|
add528f0f3 | ||
|
|
b8cff4445d | ||
|
|
a2d51ce04e | ||
|
|
109a093f86 | ||
|
|
c7265bdb46 | ||
|
|
f93edef2d3 | ||
|
|
5c780c7b82 | ||
|
|
303fcd0430 |
@@ -62,7 +62,7 @@ patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', {
|
||||
const dom1 = buttonsDom.children('.o_form_button_save')
|
||||
const dom2 = buttonsDom.children('.o_form_button_cancel')
|
||||
dom1.append('保存')
|
||||
dom2.append('放弃保存')
|
||||
dom2.append('不保存')
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
|
||||
@@ -21,13 +21,23 @@ class jikimo_purchase_tier_validation(models.Model):
|
||||
|
||||
def button_confirm(self):
|
||||
for record in self:
|
||||
if record.need_validation and record.validation_status != 'validated':
|
||||
raise ValidationError(_('此操作需要至少对一条记录进行审批。\n请发起审批申请。'))
|
||||
# if record.need_validation and record.validation_status != 'validated':
|
||||
# raise ValidationError(_('此操作需要至少对一条记录进行审批。\n请发起审批申请。'))
|
||||
if record.state in ['to approve']:
|
||||
raise ValidationError(_('请先完成审批。'))
|
||||
# if record.state == 'approved':
|
||||
# record.state = 'purchase'
|
||||
res = super(jikimo_purchase_tier_validation, self).button_confirm()
|
||||
for record in self:
|
||||
if record.state == 'approved':
|
||||
record.state = 'purchase'
|
||||
return super().button_confirm()
|
||||
record.order_line._validate_analytic_distribution()
|
||||
record._add_supplier_to_product()
|
||||
# Deal with double validation process
|
||||
if record._approval_allowed():
|
||||
record.button_approve()
|
||||
if record.partner_id not in record.message_partner_ids:
|
||||
record.message_subscribe([record.partner_id.id])
|
||||
return res
|
||||
|
||||
# def button_confirm(self):
|
||||
# self = self.with_context(skip_validation=True)
|
||||
@@ -87,15 +97,14 @@ class jikimo_purchase_tier_validation(models.Model):
|
||||
|
||||
def _validate_tier(self, tiers=False):
|
||||
res = super(jikimo_purchase_tier_validation, self)._validate_tier(tiers)
|
||||
tier_reviews = tiers or self.review_ids
|
||||
|
||||
# 检查是否所有审批都已通过
|
||||
all_approved = all(
|
||||
tier_review.status == 'approved'
|
||||
for tier_review in tier_reviews
|
||||
for tier_review in self.review_ids
|
||||
)
|
||||
|
||||
if all_approved and tier_reviews: # 确保有审批记录
|
||||
if self.review_ids and all_approved: # 确保有审批记录
|
||||
self.state = 'approved'
|
||||
|
||||
return res
|
||||
|
||||
@@ -4,6 +4,7 @@ import json
|
||||
import logging
|
||||
from odoo.addons.sf_mrs_connect.controllers.controllers import Sf_Mrs_Connect
|
||||
from odoo.addons.sf_manufacturing.controllers.controllers import Manufacturing_Connect
|
||||
from datetime import datetime
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -30,6 +31,7 @@ class WorkorderExceptionConroller(http.Controller):
|
||||
workorder = request.env['mrp.workorder'].sudo().search([
|
||||
('rfid_code', '=', ret['RfidCode']),
|
||||
('routing_type', '=', 'CNC加工'),
|
||||
('state', '!=', 'rework')
|
||||
])
|
||||
if not workorder:
|
||||
res = {'Succeed': False, 'ErrorCode': 401, 'Error': '无效的工单'}
|
||||
@@ -41,7 +43,10 @@ class WorkorderExceptionConroller(http.Controller):
|
||||
'exception_code': ret.get('coding'),
|
||||
'exception_content': ret.get('Error', '')
|
||||
})
|
||||
|
||||
# 申请重新编程
|
||||
workorder.production_id.update_programming_state(trigger_time=datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
||||
reprogramming_reason=ret.get('Error', ''))
|
||||
workorder.production_id.write({'programming_state': '编程中', 'work_state': '编程中', 'is_rework': False})
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
_logger.info('workder_exception error:%s' % e)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//notebook/page[last()]" position="after">
|
||||
<field name="routing_type" invisible="1"/>
|
||||
<page string="异常记录" name="workorder_exception" attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}">
|
||||
<field name="exception_ids" nolabel="1" readonly="1">
|
||||
<tree create="false" delete="false" edit="false">
|
||||
|
||||
@@ -132,6 +132,26 @@ class Sf_Bf_Connect(http.Controller):
|
||||
request.cr.rollback()
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@http.route('/api/bfm_cancel_order', type='http', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
def get_bfm_cancel_order(self, **kw):
|
||||
"""
|
||||
业务平台取消销售订单
|
||||
:param kw:
|
||||
:return:
|
||||
"""
|
||||
res = {'status': 1, 'message': '工厂取消销售订单成功'}
|
||||
logging.info('get_bfm_cancel_order:%s' % kw['order_number'])
|
||||
try:
|
||||
sale_order_info = request.env['sale.order'].sudo().search([('name', '=', kw['order_number'])])
|
||||
sale_order_info._action_cancel()
|
||||
return json.JSONEncoder().encode(res)
|
||||
except Exception as e:
|
||||
logging.error('get_bfm_cancel_order error: %s' % e)
|
||||
res['status'] = -1
|
||||
res['message'] = '工厂取消销售订单失败,请联系管理员'
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
|
||||
class jdElcp(http.Controller):
|
||||
|
||||
|
||||
@@ -596,6 +596,9 @@ class Manufacturing_Connect(http.Controller):
|
||||
if panel_workorder:
|
||||
panel_workorder.write({'production_line_state': '已下产线'})
|
||||
workorder.write({'state': 'to be detected'})
|
||||
workorder.check_ids.filtered(
|
||||
lambda ch: ch.quality_state == 'waiting').write(
|
||||
{'quality_state': 'none'})
|
||||
else:
|
||||
res = {'Succeed': False, 'ErrorCode': 204,
|
||||
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
||||
|
||||
@@ -350,7 +350,7 @@ class MrpProduction(models.Model):
|
||||
if any((wo.test_results == '返工' and wo.state == 'done' and
|
||||
(production.programming_state in ['已编程'] or wo.individuation_page_PTD is True))
|
||||
or (wo.is_rework is True and wo.state == 'done' and production.programming_state in ['编程中', '已编程'])
|
||||
for wo in production.workorder_ids):
|
||||
for wo in production.workorder_ids) or production.is_rework is True:
|
||||
production.state = 'rework'
|
||||
if any(wo.test_results == '报废' and wo.state == 'done' for wo in production.workorder_ids):
|
||||
production.state = 'scrap'
|
||||
@@ -577,16 +577,19 @@ class MrpProduction(models.Model):
|
||||
|
||||
# 编程单更新
|
||||
# 增加触发时间参数
|
||||
def update_programming_state(self, trigger_time=None):
|
||||
def update_programming_state(self, trigger_time=None, reprogramming_reason=None):
|
||||
try:
|
||||
manufacturing_type = 'rework'
|
||||
manufacturing_type = None
|
||||
if self.is_scrap:
|
||||
manufacturing_type = 'scrap'
|
||||
elif self.tool_state == '2':
|
||||
manufacturing_type = 'invalid_tool_rework'
|
||||
elif self.is_rework:
|
||||
manufacturing_type = 'rework'
|
||||
res = {'programming_no': self.programming_no,
|
||||
'manufacturing_type': manufacturing_type,
|
||||
'trigger_time': trigger_time}
|
||||
'trigger_time': trigger_time,
|
||||
'reprogramming_reason': reprogramming_reason}
|
||||
logging.info('res=%s:' % res)
|
||||
configsettings = self.env['res.config.settings'].get_values()
|
||||
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||
@@ -1256,9 +1259,9 @@ class MrpProduction(models.Model):
|
||||
'default_production_id': self.id,
|
||||
'default_workorder_ids': workorder_ids.ids if workorder_ids.ids != [] else self.workorder_ids.ids,
|
||||
'default_hidden_workorder_ids': ','.join(map(str, work_id_list)) if work_id_list != [] else '',
|
||||
'default_reprogramming_num': cloud_programming.get('reprogramming_num'),
|
||||
'default_programming_state': cloud_programming.get('programming_state'),
|
||||
'default_is_reprogramming': True if cloud_programming.get('programming_state') in ['已下发'] else False
|
||||
'default_reprogramming_num': cloud_programming.get('reprogramming_num') if cloud_programming else '',
|
||||
'default_programming_state': cloud_programming.get('programming_state') if cloud_programming else '',
|
||||
'default_is_reprogramming': True if cloud_programming and (cloud_programming.get('programming_state') in ['已下发']) else False
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1302,6 +1305,7 @@ class MrpProduction(models.Model):
|
||||
# 对制造订单所以面的cnc工单的程序用刀进行校验
|
||||
try:
|
||||
logging.info(f'已更新制造订单:{productions_not_delivered}')
|
||||
productions = productions.filtered(lambda p: p.production_type == '自动化产线加工')
|
||||
productions.production_cnc_tool_checkout()
|
||||
except Exception as e:
|
||||
logging.info(f'对cnc工单的程序用刀进行校验报错:{e}')
|
||||
@@ -1526,15 +1530,16 @@ class MrpProduction(models.Model):
|
||||
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 != '自加工'
|
||||
is_customer_provided = product_id.is_customer_provided
|
||||
if not is_custemer_group_id.get(is_customer_provided) and is_self_process:
|
||||
is_custemer_group_id[is_customer_provided] = self.env["procurement.group"].create({'name': vals.get('name')}).id
|
||||
key = f"{is_self_process}_{is_customer_provided}"
|
||||
if not is_custemer_group_id.get(key):
|
||||
is_custemer_group_id[key] = self.env["procurement.group"].create({'name': vals.get('name')}).id
|
||||
# if not (is_first_customer or is_first_not_customer) 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'):
|
||||
if product_id.product_tmpl_id.single_manufacturing:
|
||||
if product_id.categ_id.name == '成品' and is_self_process:
|
||||
vals['procurement_group_id'] = is_custemer_group_id[is_customer_provided]
|
||||
if product_id.categ_id.name == '成品':
|
||||
vals['procurement_group_id'] = is_custemer_group_id[key]
|
||||
continue
|
||||
if product_id.id not in product_group_id.keys():
|
||||
procurement_group_vals = self._prepare_procurement_group_vals(vals)
|
||||
@@ -1544,7 +1549,7 @@ class MrpProduction(models.Model):
|
||||
else:
|
||||
vals['procurement_group_id'] = product_group_id[product_id.id]
|
||||
else:
|
||||
vals['procurement_group_id'] = is_custemer_group_id[is_customer_provided]
|
||||
vals['procurement_group_id'] = is_custemer_group_id[key]
|
||||
return super(MrpProduction, self).create(vals_list)
|
||||
|
||||
@api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id',
|
||||
@@ -1673,13 +1678,13 @@ class MrpProduction(models.Model):
|
||||
url = '/api/intelligent_programming/reset_state_again'
|
||||
config_url = configsettings['sf_url'] + url
|
||||
ret = requests.post(config_url, json=res, data=None, headers=config_header)
|
||||
ret = ret.json()
|
||||
result = json.loads(ret['result'])
|
||||
logging.info('update_programming_state-ret:%s' % result)
|
||||
if result['status'] == 1:
|
||||
self.write({'is_rework': True})
|
||||
else:
|
||||
raise UserError(ret['message'])
|
||||
# ret = ret.json()
|
||||
# result = json.loads(ret['result'])
|
||||
# logging.info('update_programming_state-ret:%s' % result)
|
||||
# if result['status'] == 1:
|
||||
# self.write({'is_rework': True})
|
||||
# else:
|
||||
# raise UserError(ret['message'])
|
||||
except Exception as e:
|
||||
logging.info('update_programming_state error:%s' % e)
|
||||
raise UserError("更新编程单状态失败,请联系管理员")
|
||||
|
||||
@@ -455,6 +455,32 @@ class ResMrpWorkOrder(models.Model):
|
||||
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因", tracking=True)
|
||||
detailed_reason = fields.Text('详细原因')
|
||||
is_rework = fields.Boolean(string='是否返工', default=False)
|
||||
# rework_flag = fields.Boolean(string='返工标志', compute='_compute_rework_flag')
|
||||
#
|
||||
# @api.depends('state', 'production_line_state')
|
||||
# def _compute_rework_flag(self):
|
||||
# for record in self:
|
||||
# if record.state == 'done' and record.routing_type == '装夹预调':
|
||||
# next_workorder = record.production_id.workorder_ids.filtered(
|
||||
# lambda w: w.sequence == record.sequence + 1)
|
||||
# if next_workorder and next_workorder.routing_type == 'CNC加工' and next_workorder.state in ['ready',
|
||||
# 'waiting',
|
||||
# 'pending'] and next_workorder.production_line_state == '待上产线':
|
||||
# record.rework_flag = False
|
||||
# elif next_workorder and next_workorder.routing_type == '表面工艺' and next_workorder.state in ['ready',
|
||||
# 'waiting',
|
||||
# 'pending']:
|
||||
# record.rework_flag = False
|
||||
# else:
|
||||
# record.rework_flag = True
|
||||
# else:
|
||||
# record.rework_flag = True
|
||||
#
|
||||
# def button_rework(self):
|
||||
# for item in self:
|
||||
# item.state = 'progress'
|
||||
# for time_id in item.time_ids:
|
||||
# time_id.write({'date_end': None})
|
||||
|
||||
def button_change_env(self):
|
||||
self.is_test_env = not self.is_test_env
|
||||
@@ -1503,7 +1529,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
store=True)
|
||||
individuation_page_ids = fields.Many2many('sf.work.individuation.page', string='个性化记录', store=True,
|
||||
compute='_compute_individuation_page_ids')
|
||||
individuation_page_PTD = fields.Boolean('个性化记录(后置三元检测PTD)', default=False)
|
||||
individuation_page_PTD = fields.Boolean('个性化记录(是否显示后置三元检测[PTD]页签)', default=False)
|
||||
|
||||
@api.depends('name')
|
||||
def _compute_routing_workcenter_id(self):
|
||||
@@ -1543,7 +1569,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
# 修改工单状态
|
||||
self.write({'state': 'to be detected'})
|
||||
# 若关联的【质量检查_需送检】=true,则质量检查单的状态从“等待”更新为“待处理”
|
||||
self.check_ids.filtered(lambda ch: ch.is_inspect is True).write({'quality_state': 'none'})
|
||||
self.check_ids.filtered(lambda ch: ch.is_inspect is True and ch.quality_state == 'waiting').write(
|
||||
{'quality_state': 'none'})
|
||||
|
||||
|
||||
class CNCprocessing(models.Model):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import logging
|
||||
import json
|
||||
from odoo import models, fields, api
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@@ -24,6 +24,8 @@ class SaleOrder(models.Model):
|
||||
self.state = 'supply method'
|
||||
|
||||
def action_confirm(self):
|
||||
if self._get_forbidden_state_confirm() & set(self.mapped('state')):
|
||||
raise UserError(_('订单状态已发生变化,请刷新当前页面'))
|
||||
# 判断是否所有产品都选择了供货方式
|
||||
filter_line = self.order_line.filtered(lambda line: not line.supply_method)
|
||||
if filter_line:
|
||||
|
||||
@@ -180,14 +180,14 @@ class StockRule(models.Model):
|
||||
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
|
||||
productions_values)
|
||||
# 将这一批制造订单的采购组根据成品设置为不同的采购组
|
||||
product_group_id = {}
|
||||
for index, production in enumerate(productions):
|
||||
if production.product_id.id not in product_group_id.keys():
|
||||
product_group_id[production.product_id.id] = production.procurement_group_id.id
|
||||
else:
|
||||
productions_values[index].update({'name': production.name})
|
||||
procurement_group_vals = production._prepare_procurement_group_vals(productions_values[index])
|
||||
production.procurement_group_id = self.env["procurement.group"].create(procurement_group_vals).id
|
||||
# product_group_id = {}
|
||||
# for index, production in enumerate(productions):
|
||||
# if production.product_id.id not in product_group_id.keys():
|
||||
# product_group_id[production.product_id.id] = production.procurement_group_id.id
|
||||
# else:
|
||||
# productions_values[index].update({'name': production.name})
|
||||
# procurement_group_vals = production._prepare_procurement_group_vals(productions_values[index])
|
||||
# production.procurement_group_id = self.env["procurement.group"].create(procurement_group_vals).id
|
||||
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||
@@ -197,7 +197,7 @@ class StockRule(models.Model):
|
||||
'''
|
||||
# productions._create_workorder()
|
||||
#
|
||||
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
||||
(
|
||||
p.move_dest_ids.procure_method != 'make_to_order' and not
|
||||
@@ -289,7 +289,7 @@ class StockRule(models.Model):
|
||||
if production_item.product_id.id in product_id_to_production_names:
|
||||
# 同一个产品多个制造订单对应一个编程单和模型库
|
||||
# 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
||||
if not production_item.programming_no and production_item.production_type == '自动化产线加工':
|
||||
if not production_item.programming_no and production_item.production_type in ['自动化产线加工', '人工线下加工']:
|
||||
if not production_programming.programming_no:
|
||||
production_item.fetchCNC(
|
||||
', '.join(product_id_to_production_names[production_item.product_id.id]))
|
||||
|
||||
@@ -74,7 +74,9 @@
|
||||
<xpath expr="//field[@name='production_real_duration']" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//field[@name='state']" position="after">
|
||||
<field name="programming_state" optional="hide"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -115,11 +117,11 @@
|
||||
<xpath expr="//sheet//group//group//div[3]" position="after">
|
||||
<field name="production_type" readonly="1"/>
|
||||
<field name="manual_quotation" readonly="1"
|
||||
attrs="{'invisible': [('production_type', 'not in', ['自动化产线加工'])]}"/>
|
||||
attrs="{'invisible': [('production_type', 'not in', ['自动化产线加工', '人工线下加工'])]}"/>
|
||||
<field name="programming_no" readonly="1"
|
||||
attrs="{'invisible': [('production_type', 'not in', ['自动化产线加工'])]}"/>
|
||||
attrs="{'invisible': [('production_type', 'not in', ['自动化产线加工', '人工线下加工'])]}"/>
|
||||
<field name="programming_state" readonly="1"
|
||||
attrs="{'invisible': [('production_type', 'not in', ['自动化产线加工'])]}"
|
||||
attrs="{'invisible': [('production_type', 'not in', ['自动化产线加工', '人工线下加工'])]}"
|
||||
decoration-success="programming_state == '已编程'"
|
||||
decoration-warning="programming_state =='编程中'"
|
||||
decoration-danger="programming_state =='已编程未下发'"/>
|
||||
@@ -630,6 +632,8 @@
|
||||
<field name="state" icon="fa-filter" enable_counters="1"/>
|
||||
<field name="delivery_status" icon="fa-filter" enable_counters="1"/>
|
||||
<field name="production_type" icon="fa-filter" enable_counters="1"/>
|
||||
<field name="programming_state" icon="fa-filter" enable_counters="1"/>
|
||||
|
||||
</searchpanel>
|
||||
</xpath>
|
||||
<filter name='todo' position="replace"/>
|
||||
|
||||
@@ -126,9 +126,10 @@
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
||||
<field name="arch" type="xml">
|
||||
<form position="inside">
|
||||
<field name="_barcode_scanned" widget="barcode_handler" invisible="1"/>
|
||||
</form>
|
||||
<xpath expr="//form" position="inside">
|
||||
<!-- 其他可见字段 -->
|
||||
<field name="_barcode_scanned" widget="barcode_handler"/>
|
||||
</xpath>
|
||||
<!-- <xpath expr="//form" position="inside"> -->
|
||||
<!-- <script src="sf_manufacturing/static/src/js/customRFID.js"/> -->
|
||||
<!-- </xpath> -->
|
||||
@@ -162,6 +163,7 @@
|
||||
<field name='is_delivery' invisible="1"/>
|
||||
<field name="is_trayed" invisible="1"/>
|
||||
<field name="is_inspect" invisible="1"/>
|
||||
<!-- <field name="rework_flag" invisible="1"/>-->
|
||||
<!-- <field name='is_send_program_again' invisible="1"/>-->
|
||||
<!-- 工单form页面的开始停工按钮等 -->
|
||||
<!-- <button name="button_start" type="object" string="开始" class="btn-success" -->
|
||||
@@ -181,7 +183,7 @@
|
||||
<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="是否确认完工"
|
||||
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>
|
||||
attrs="{'invisible': ['|', '|', '|',('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False),'&','&',('state', 'in', ('progress')), ('is_inspect', '=', True), ('routing_type','!=','CNC加工')]}"/>
|
||||
|
||||
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="阻塞"
|
||||
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
|
||||
@@ -210,6 +212,9 @@
|
||||
attrs="{'invisible': ['|', '|', '|', ('routing_type','!=','装夹预调'),('state','!=','progress'), ('is_trayed', '=', False), ('state', 'in', ('done'))]}"/>
|
||||
<button name="print_method" type="object" string="打印二维码" class="btn-primary"
|
||||
attrs="{'invisible': ['|',('routing_type','!=','解除装夹'),('state','!=','done')]}"/>
|
||||
<!-- <button type="object" class="oe_highlight jikimo_button_confirm" name="button_rework"-->
|
||||
<!-- string="返工"-->
|
||||
<!-- attrs='{"invisible": [("rework_flag","=",True)]}' confirm="是否返工"/>-->
|
||||
</xpath>
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<page string="开料要求" attrs='{"invisible": [("routing_type","not in",("切割", "线切割", "人工线下加工"))]}'>
|
||||
@@ -311,7 +316,7 @@
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<page string="工件装夹" attrs='{"invisible": [("routing_type","!=","装夹预调")]}'>
|
||||
<group>
|
||||
<field name="_barcode_scanned" widget="barcode_handler"/>
|
||||
<!-- <field name="_barcode_scanned" widget="barcode_handler"/> -->
|
||||
<group string="托盘">
|
||||
<field name="tray_serial_number" readonly="1" string="序列号"/>
|
||||
</group>
|
||||
@@ -488,7 +493,7 @@
|
||||
</group>
|
||||
</page>
|
||||
|
||||
<page string="2D加工图纸" attrs="{'invisible': [('routing_type','!=','装夹预调')]}">
|
||||
<page string="2D加工图纸" attrs='{"invisible": [("routing_type","not in",["装夹预调", "人工线下加工"])]}'>
|
||||
<field name="machining_drawings" widget="adaptive_viewer"/>
|
||||
</page>
|
||||
|
||||
@@ -532,15 +537,15 @@
|
||||
<page string="后置三元检测" attrs='{"invisible": [("individuation_page_PTD", "=", False)]}'>
|
||||
<group>
|
||||
<field name="test_results"
|
||||
attrs='{"readonly":[("state","!=","to be detected"), "|",("routing_type","=","CNC加工"),("is_inspect", "=", True)],
|
||||
attrs='{"readonly":["&","|",("state","!=","to be detected"), "|",("routing_type","=","CNC加工"),("is_inspect", "=", True),("state","in",["done","rework"])],
|
||||
"invisible":[("results","!=",False)]}'/>
|
||||
<!-- <field name="is_remanufacture" attrs='{"invisible":[("test_results","!=","报废")]}'/>-->
|
||||
<!-- <field name="is_fetchcnc"-->
|
||||
<!-- attrs='{"invisible":["|",("test_results","=","合格"),("is_remanufacture","=",False)]}'/>-->
|
||||
<field name="reason"
|
||||
attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")]}'/>
|
||||
attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")],"readonly":[("state","in",("done", "rework"))]}'/>
|
||||
<field name="detailed_reason"
|
||||
attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")]}'/>
|
||||
attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")],"readonly":[("state","in",("done", "rework"))]}'/>
|
||||
<!-- <field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>-->
|
||||
<field name="detection_report" attrs='{"invisible":[("results","!=",False)]}'
|
||||
widget="pdf_viewer" readonly="1"/>
|
||||
@@ -560,7 +565,7 @@
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<page string="CNC程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<page string="CNC程序" attrs='{"invisible": [("routing_type","not in",["CNC加工", "人工线下加工"])]}'>
|
||||
<field name="cnc_ids" widget="one2many" string="工作程序" default_order="sequence_number,id"
|
||||
readonly="0">
|
||||
<tree>
|
||||
@@ -584,7 +589,7 @@
|
||||
</field>
|
||||
|
||||
</page>
|
||||
<page string="CMM程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<page string="CMM程序" attrs='{"invisible": [("routing_type","not in",["CNC加工", "人工线下加工"])]}'>
|
||||
<field name="cmm_ids" widget="one2many" string="CMM程序" readonly="1">
|
||||
<tree>
|
||||
<field name="sequence_number"/>
|
||||
@@ -637,7 +642,7 @@
|
||||
<field name="inherit_id" ref="sf_manufacturing.view_mrp_production_workorder_tray_form_inherit_sf"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form//sheet//group//group[2]" position="replace">
|
||||
<group string="装夹图纸" attrs="{'invisible': [('routing_type', '!=', '装夹预调')]}">
|
||||
<group string="装夹图纸" attrs="{'invisible': [('routing_type', 'not in', ['装夹预调', '人工线下加工'])]}">
|
||||
<!-- 隐藏加工图纸字段名 -->
|
||||
<field name="processing_drawing" widget="pdf_viewer" string="" readonly="1"/>
|
||||
<!-- <field name="production_id" invisible="0"/>-->
|
||||
|
||||
@@ -4,8 +4,14 @@
|
||||
<record model="ir.ui.view" id="view_purchase_order_line_form_inherit_sf1">
|
||||
<field name="name">purchase.order.form.inherit.sf</field>
|
||||
<field name="model">purchase.order</field>
|
||||
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
||||
<field name="inherit_id" ref="purchase_order_approved.purchase_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="order_line" position="attributes">
|
||||
<attribute
|
||||
name="attrs"
|
||||
>{'readonly': [('state', '!=', 'draft')]}
|
||||
</attribute>
|
||||
</field>
|
||||
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="after">
|
||||
<field name="related_product" optional="show"/>
|
||||
<field name="part_number" optional="show"/>
|
||||
|
||||
@@ -281,7 +281,8 @@ class ReworkWizard(models.TransientModel):
|
||||
{'programming_state': '编程中', 'work_state': '编程中', 'is_rework': True})
|
||||
# =================================================
|
||||
if self.production_id.state == 'progress':
|
||||
self.production_id.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||
if self.programming_state:
|
||||
self.production_id.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||
if self.reprogramming_num >= 1 and self.programming_state == '已编程':
|
||||
productions_not_delivered = self.env['mrp.production'].search(
|
||||
[('programming_no', '=', self.production_id.programming_no),
|
||||
|
||||
@@ -16,6 +16,7 @@ class SFMessageProduct(models.Model):
|
||||
mrp_production_list = self.env['mrp.production'].sudo().search(
|
||||
[('product_id', '=', product_product.id)])
|
||||
production_num = 0
|
||||
routing_type = None
|
||||
for mrp_production_info in mrp_production_list:
|
||||
routing_type = '人工线下加工' if mrp_production_info.production_type == '人工线下加工' else '装夹预调'
|
||||
mrp_production_ready = mrp_production_info.workorder_ids.filtered(
|
||||
@@ -23,7 +24,7 @@ class SFMessageProduct(models.Model):
|
||||
if mrp_production_ready:
|
||||
production_num += 1
|
||||
if production_num >= 1:
|
||||
url = self.get_request_url()
|
||||
url = self.get_request_url(routing_type)
|
||||
content = content.replace('{{product_id}}', product_product.name).replace(
|
||||
'{{number}}', str(production_num)).replace(
|
||||
'{{request_url}}', url)
|
||||
@@ -42,11 +43,15 @@ class SFMessageProduct(models.Model):
|
||||
contents.append(content)
|
||||
return contents, message_queue_ids
|
||||
|
||||
def get_request_url(self):
|
||||
def get_request_url(self, routing_type):
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
action_id = self.env.ref('sf_message.mrp_workorder_issued_action').id
|
||||
menu_id = self.env.ref('mrp.menu_mrp_root').id
|
||||
active_id = self.env['mrp.workcenter'].sudo().search([('name', '=', '工件装夹中心')]).id
|
||||
if routing_type == '人工线下加工':
|
||||
routing_name = '线下工作中心'
|
||||
else:
|
||||
routing_name = '工件装夹中心'
|
||||
active_id = self.env['mrp.workcenter'].sudo().search([('name', '=', routing_name)]).id
|
||||
# 查询参数
|
||||
params = {'menu_id': menu_id, 'action': action_id, 'model': 'mrp.workorder',
|
||||
'view_type': 'list', 'active_id': active_id}
|
||||
|
||||
@@ -200,6 +200,17 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
'send_time': ret['send_time'],
|
||||
})
|
||||
logging.info('已创建无效功能刀具的编程记录:%s' % production.name)
|
||||
elif ret['reprogramming_reason']:
|
||||
production.programming_record_ids.create({
|
||||
'number': len(production.programming_record_ids) + 1,
|
||||
'production_id': production.id,
|
||||
'reason': ret['reprogramming_reason'],
|
||||
'programming_method': ret['programme_way'],
|
||||
'current_programming_count': ret['reprogramming_num'],
|
||||
'target_production_id': productions_reprogram,
|
||||
'apply_time': ret['trigger_time'],
|
||||
'send_time': ret['send_time'],
|
||||
})
|
||||
else:
|
||||
logging.info('无对应状态,不需更新编程记录')
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
'security/ir.model.access.csv',
|
||||
'views/view.xml',
|
||||
'views/quality_cnc_test_view.xml',
|
||||
'views/mrp_workorder.xml',
|
||||
'views/quality_check_view.xml'
|
||||
],
|
||||
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
from . import custom_quality
|
||||
from . import quality
|
||||
from . import quality_cnc_test
|
||||
from . import mrp_workorder
|
||||
|
||||
28
sf_quality/models/mrp_workorder.py
Normal file
28
sf_quality/models/mrp_workorder.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ResMrpWorkOrder(models.Model):
|
||||
_inherit = 'mrp.workorder'
|
||||
|
||||
check_ids_state = fields.Selection([('none', '待处理'), ('pass', '通过的'), ('fail', '失败的')], store=True,
|
||||
compute='_compute_check_ids_state')
|
||||
|
||||
@api.depends('check_ids.quality_state')
|
||||
def _compute_check_ids_state(self):
|
||||
for mw in self:
|
||||
if mw.check_ids:
|
||||
if all(check_id.quality_state == 'pass' for check_id in mw.check_ids):
|
||||
mw.check_ids_state = 'pass'
|
||||
elif any(check_id.quality_state == 'fail' for check_id in mw.check_ids):
|
||||
mw.check_ids_state = 'fail'
|
||||
else:
|
||||
mw.check_ids_state = 'none'
|
||||
|
||||
def action_open_quality_check_work_sf(self):
|
||||
return {
|
||||
'res_model': 'quality.check',
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': '质量检查',
|
||||
'domain': [('workorder_id', '=', self.id)],
|
||||
'view_mode': 'tree,form',
|
||||
}
|
||||
@@ -17,6 +17,7 @@ class QualityCheck(models.Model):
|
||||
('fail', '失败的')], string='状态', tracking=True, store=True,
|
||||
default='none', copy=False, compute='_compute_quality_state')
|
||||
|
||||
individuation_page_PTD = fields.Boolean('个性化记录(是否显示后置三元检测[PTD]页签)', related='workorder_id.individuation_page_PTD')
|
||||
work_state = fields.Selection(related='workorder_id.state', string='工单状态')
|
||||
processing_panel = fields.Char(related='workorder_id.processing_panel', string='加工面')
|
||||
|
||||
@@ -26,7 +27,7 @@ class QualityCheck(models.Model):
|
||||
model_file = fields.Binary(related='workorder_id.glb_file', string='加工模型')
|
||||
|
||||
detection_report = fields.Binary(related='workorder_id.detection_report', readonly=True, string='检测报告')
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], string="检测结果",
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工")], string="检测结果",
|
||||
default='合格')
|
||||
reason = fields.Selection(
|
||||
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"), ("operate computer", "操机"),
|
||||
@@ -47,7 +48,7 @@ class QualityCheck(models.Model):
|
||||
@api.depends('point_id.is_inspect')
|
||||
def _compute_quality_state(self):
|
||||
for qc in self:
|
||||
if qc.point_id.is_inspect and qc.quality_state == 'none':
|
||||
if qc.point_id.is_inspect and qc.quality_state == 'none' and qc.workorder_id.state != 'to be detected':
|
||||
qc.quality_state = 'waiting'
|
||||
elif not qc.point_id.is_inspect and qc.quality_state == 'waiting':
|
||||
qc.quality_state = 'none'
|
||||
@@ -62,6 +63,8 @@ class QualityCheck(models.Model):
|
||||
self.ensure_one()
|
||||
super().do_pass()
|
||||
if self.workorder_id:
|
||||
if self.workorder_id.state in ('pending', 'waiting'):
|
||||
raise ValidationError('工单未就绪!')
|
||||
# 1)将页签“判定结果”的检测结果值同步到【工单_后置三元检测_检测结果】
|
||||
if self.test_results in ['返工', '报废']:
|
||||
raise ValidationError('请重新选择【判定结果】-【检测结果】')
|
||||
@@ -74,6 +77,8 @@ class QualityCheck(models.Model):
|
||||
self.ensure_one()
|
||||
super().do_fail()
|
||||
if self.workorder_id:
|
||||
if self.workorder_id.state in ('pending', 'waiting'):
|
||||
raise ValidationError('工单未就绪!')
|
||||
# 1)将页签“判定结果”的检测结果值同步到【工单_后置三元检测_检测结果】
|
||||
if not self.test_results:
|
||||
raise ValidationError('请填写【判定结果】里的信息')
|
||||
|
||||
22
sf_quality/views/mrp_workorder.xml
Normal file
22
sf_quality/views/mrp_workorder.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="mrp_workorder_quality_form_view_inherit" model="ir.ui.view">
|
||||
<field name="name">mrp.workorder.view.form.inherit.quality</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
||||
<field name="arch" type="xml">
|
||||
<div name="button_box" position="inside">
|
||||
<field name="check_ids_state" invisible="1"/>
|
||||
<button name="action_open_quality_check_work_sf" groups="quality.group_quality_user" attrs="{'invisible': ['|',('check_ids_state', '!=', 'none'), ('check_ids', '=', [])]}" type="object" class="oe_stat_button" icon="fa-check">
|
||||
<span class="o_stat_text">质量检查</span>
|
||||
</button>
|
||||
<button name="action_open_quality_check_work_sf" groups="quality.group_quality_user" attrs="{'invisible': ['|',('check_ids_state', '!=', 'pass'), ('check_ids', '=', [])]}" type="object" class="oe_stat_button text-success" icon="fa-check">
|
||||
<span class="o_stat_text text-success">质量检查</span>
|
||||
</button>
|
||||
<button name="action_open_quality_check_work_sf" groups="quality.group_quality_user" attrs="{'invisible': ['|',('check_ids_state', '!=', 'fail'), ('check_ids', '=', [])]}" type="object" class="oe_stat_button text-danger" icon="fa-check">
|
||||
<span class="o_stat_text text-danger">质量检查</span>
|
||||
</button>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -8,13 +8,16 @@
|
||||
<xpath expr="//field[@name='alert_ids']" position="after">
|
||||
<field name="production_id" invisible="1"/>
|
||||
<field name="work_state" invisible="1"/>
|
||||
<field name="individuation_page_PTD" invisible="1"/>
|
||||
<field name="production_line_id" attrs="{'invisible': [('production_id', '=', False)]}"/>
|
||||
<field name="equipment_id" attrs="{'invisible': [('production_id', '=', False)]}"/>
|
||||
<field name="model_file" widget="Viewer3D" string="模型" readonly="1" force_save="1"
|
||||
attrs="{'invisible': ['|', ('model_file', '=', False), ('production_id', '=', False)]}"/>
|
||||
attrs="{'invisible': ['|',('model_file', '=', False), ('production_id', '=', False)]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='partner_id']" position="after">
|
||||
<field name="processing_panel" attrs="{'invisible': [('production_id', '=', False)]}"/>
|
||||
<!-- <field name="production_id" string="制造订单" readonly="1"-->
|
||||
<!-- attrs="{'invisible': [('production_id', '=', False)]}"/>-->
|
||||
<field name="workorder_id" string="工单号" readonly="1"
|
||||
attrs="{'invisible': [('production_id', '=', False)]}"/>
|
||||
<field name="is_inspect" attrs="{'invisible': [('production_id', '=', False)]}"/>
|
||||
@@ -41,18 +44,26 @@
|
||||
<field name="quality_standard" string="" widget="adaptive_viewer"/>
|
||||
</page>
|
||||
<page string="其他"
|
||||
attrs="{'invisible': ['|', ('quality_state', 'not in', ['pass', 'fail']), ('production_id', '=', False)]}">
|
||||
attrs="{'invisible': ['|',('quality_state', 'not in', ['pass', 'fail']), ('production_id', '=', False)]}">
|
||||
<group>
|
||||
<field name="write_uid" widget='many2one_avatar_user' string="判定人" readonly="1"/>
|
||||
<field name="write_date" string="判定时间" readonly="1"/>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//header//button[@name='do_pass'][1]" position="attributes">
|
||||
<attribute name="string">合格</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//header//button[@name='do_pass'][2]" position="attributes">
|
||||
<attribute name="attrs">{'invisible': ['|',('quality_state', '!=', 'fail'),('work_state','in', ('done', 'rework'))]}</attribute>
|
||||
<attribute name="string">合格</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//header//button[@name='do_fail'][1]" position="attributes">
|
||||
<attribute name="string">不合格</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//header//button[@name='do_fail'][2]" position="attributes">
|
||||
<attribute name="attrs">{'invisible': ['|',('quality_state', '!=', 'pass'),('work_state','in', ('done', 'rework'))]}</attribute>
|
||||
<attribute name="string">不合格</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -130,7 +130,10 @@ class ReSaleOrder(models.Model):
|
||||
'order_id': self.id,
|
||||
'product_id': product.id,
|
||||
'name': '%s/%s/%s/%s/%s/%s' % (
|
||||
product.model_long, product.model_width, product.model_height, product.model_volume,
|
||||
self.format_float(product.model_long),
|
||||
self.format_float(product.model_width),
|
||||
self.format_float(product.model_height),
|
||||
self.format_float(product.model_volume),
|
||||
machining_accuracy_name,
|
||||
product.materials_id.name),
|
||||
'price_unit': product.list_price,
|
||||
@@ -143,6 +146,20 @@ class ReSaleOrder(models.Model):
|
||||
}
|
||||
return self.env['sale.order.line'].with_context(skip_procurement=True).create(vals)
|
||||
|
||||
def format_float(self, value):
|
||||
# 将浮点数转换为字符串
|
||||
value_str = str(value)
|
||||
# 检查小数点的位置
|
||||
if '.' in value_str:
|
||||
# 获取小数部分
|
||||
decimal_part = value_str.split('.')[1]
|
||||
# 判断小数位数是否超过2位
|
||||
if len(decimal_part) > 2:
|
||||
# 超过2位则保留2位小数
|
||||
return "{:.2f}".format(value)
|
||||
# 否则保持原来的位数
|
||||
return float(value_str)
|
||||
|
||||
@api.constrains('order_line')
|
||||
def check_order_line(self):
|
||||
for item in self:
|
||||
|
||||
Reference in New Issue
Block a user