Compare commits
20 Commits
feature/加工
...
feature/增加
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98b338f33a | ||
|
|
b619c15231 | ||
|
|
9efa4636d9 | ||
|
|
0b2b9c2bf5 | ||
|
|
cc5036ce64 | ||
|
|
2dc54792f4 | ||
|
|
5db877a54c | ||
|
|
6bff1f2f64 | ||
|
|
0aaa3bd5ba | ||
|
|
39d6c8ae24 | ||
|
|
2c56011502 | ||
|
|
1e71fc1b08 | ||
|
|
add528f0f3 | ||
|
|
b8cff4445d | ||
|
|
a2d51ce04e | ||
|
|
109a093f86 | ||
|
|
c7265bdb46 | ||
|
|
f93edef2d3 | ||
|
|
5c780c7b82 | ||
|
|
303fcd0430 |
@@ -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
|
||||
|
||||
@@ -1256,9 +1256,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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1526,15 +1526,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 +1545,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',
|
||||
|
||||
@@ -1503,7 +1503,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):
|
||||
|
||||
@@ -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">
|
||||
<xpath expr="//sheet" position="inside">
|
||||
<!-- 其他可见字段 -->
|
||||
<field name="_barcode_scanned" widget="barcode_handler" invisible="1"/>
|
||||
</form>
|
||||
</xpath>
|
||||
<!-- <xpath expr="//form" position="inside"> -->
|
||||
<!-- <script src="sf_manufacturing/static/src/js/customRFID.js"/> -->
|
||||
<!-- </xpath> -->
|
||||
@@ -538,9 +539,9 @@
|
||||
<!-- <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"/>
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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", "操机"),
|
||||
@@ -61,7 +62,7 @@ class QualityCheck(models.Model):
|
||||
def do_pass(self):
|
||||
self.ensure_one()
|
||||
super().do_pass()
|
||||
if self.workorder_id:
|
||||
if self.workorder_id and self.individuation_page_PTD is True:
|
||||
# 1)将页签“判定结果”的检测结果值同步到【工单_后置三元检测_检测结果】
|
||||
if self.test_results in ['返工', '报废']:
|
||||
raise ValidationError('请重新选择【判定结果】-【检测结果】')
|
||||
@@ -73,7 +74,7 @@ class QualityCheck(models.Model):
|
||||
def do_fail(self):
|
||||
self.ensure_one()
|
||||
super().do_fail()
|
||||
if self.workorder_id:
|
||||
if self.workorder_id and self.individuation_page_PTD is True:
|
||||
# 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,22 +8,23 @@
|
||||
<xpath expr="//field[@name='alert_ids']" position="after">
|
||||
<field name="production_id" invisible="1"/>
|
||||
<field name="work_state" invisible="1"/>
|
||||
<field name="production_line_id" attrs="{'invisible': [('production_id', '=', False)]}"/>
|
||||
<field name="equipment_id" attrs="{'invisible': [('production_id', '=', False)]}"/>
|
||||
<field name="individuation_page_PTD" invisible="1"/>
|
||||
<field name="production_line_id" attrs="{'invisible': ['|',('production_id', '=', False), ('individuation_page_PTD', '=', False)]}"/>
|
||||
<field name="equipment_id" attrs="{'invisible': ['|',('production_id', '=', False), ('individuation_page_PTD', '=', 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), ('individuation_page_PTD', '=', False)]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='partner_id']" position="after">
|
||||
<field name="processing_panel" attrs="{'invisible': [('production_id', '=', False)]}"/>
|
||||
<field name="processing_panel" attrs="{'invisible': ['|',('production_id', '=', False), ('individuation_page_PTD', '=', False)]}"/>
|
||||
<field name="workorder_id" string="工单号" readonly="1"
|
||||
attrs="{'invisible': [('production_id', '=', False)]}"/>
|
||||
<field name="is_inspect" attrs="{'invisible': [('production_id', '=', False)]}"/>
|
||||
attrs="{'invisible': ['|',('production_id', '=', False), ('individuation_page_PTD', '=', False)]}"/>
|
||||
<field name="is_inspect" attrs="{'invisible': ['|',('production_id', '=', False), ('individuation_page_PTD', '=', False)]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='notes']" position="before">
|
||||
<page string="检测报告" attrs="{'invisible': [('production_id', '=', False)]}">
|
||||
<page string="检测报告" attrs="{'invisible': ['|',('production_id', '=', False), ('individuation_page_PTD', '=', False)]}">
|
||||
<field name="detection_report" string="" widget="pdf_viewer"/>
|
||||
</page>
|
||||
<page string="判定结果" attrs="{'invisible': [('production_id', '=', False)]}">
|
||||
<page string="判定结果" attrs="{'invisible': ['|',('production_id', '=', False), ('individuation_page_PTD', '=', False)]}">
|
||||
<group>
|
||||
<group>
|
||||
<field name="test_results" attrs="{'readonly': [('quality_state','in', ['pass', 'fail'])]}"/>
|
||||
@@ -34,14 +35,14 @@
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
<page string="2D图纸" attrs="{'invisible': [('production_id', '=', False)]}">
|
||||
<page string="2D图纸" attrs="{'invisible': ['|',('production_id', '=', False), ('individuation_page_PTD', '=', False)]}">
|
||||
<field name="machining_drawings" string="" widget="adaptive_viewer"/>
|
||||
</page>
|
||||
<page string="客户质量标准" attrs="{'invisible': [('production_id', '=', False)]}">
|
||||
<page string="客户质量标准" attrs="{'invisible': ['|',('production_id', '=', False), ('individuation_page_PTD', '=', False)]}">
|
||||
<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),('individuation_page_PTD', '=', False)]}">
|
||||
<group>
|
||||
<field name="write_uid" widget='many2one_avatar_user' string="判定人" readonly="1"/>
|
||||
<field name="write_date" string="判定时间" readonly="1"/>
|
||||
|
||||
Reference in New Issue
Block a user