Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造功能优化
This commit is contained in:
@@ -1526,8 +1526,7 @@ class MrpProduction(models.Model):
|
||||
重载创建制造订单的方法,单个制造订单,同一成品只创建一个采购组,用于后续单据的创建
|
||||
"""
|
||||
product_group_id = {}
|
||||
group_id = False
|
||||
is_first = False
|
||||
is_custemer_group_id = {} # 客供料与非客供料
|
||||
for vals in vals_list:
|
||||
if not vals.get('name', False) or vals['name'] == _('New'):
|
||||
picking_type_id = vals.get('picking_type_id')
|
||||
@@ -1537,15 +1536,16 @@ class MrpProduction(models.Model):
|
||||
vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id()
|
||||
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
|
||||
is_customer_provided = product_id.is_customer_provided
|
||||
if not is_custemer_group_id.get(is_customer_provided):
|
||||
is_custemer_group_id[is_customer_provided] = 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'] = group_id
|
||||
vals['procurement_group_id'] = is_custemer_group_id[is_customer_provided]
|
||||
continue
|
||||
if product_id.id not in product_group_id.keys():
|
||||
procurement_group_vals = self._prepare_procurement_group_vals(vals)
|
||||
@@ -1555,7 +1555,7 @@ class MrpProduction(models.Model):
|
||||
else:
|
||||
vals['procurement_group_id'] = product_group_id[product_id.id]
|
||||
else:
|
||||
vals['procurement_group_id'] = group_id
|
||||
vals['procurement_group_id'] = is_custemer_group_id[is_customer_provided]
|
||||
return super(MrpProduction, self).create(vals_list)
|
||||
|
||||
@api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id',
|
||||
|
||||
@@ -44,7 +44,9 @@ class ResMrpWorkOrder(models.Model):
|
||||
('ZM', 'ZM'),
|
||||
('FM', 'FM'),
|
||||
('YC', 'YC'),
|
||||
('QC', 'QC')], string="加工面", compute='_compute_processing_panel_selection', store=True)
|
||||
('QC', 'QC'),
|
||||
('HC', 'HC'),
|
||||
('ZC', 'ZC')], string="加工面", compute='_compute_processing_panel_selection', store=True)
|
||||
sequence = fields.Integer(string='工序')
|
||||
routing_type = fields.Selection([
|
||||
('装夹预调', '装夹预调'),
|
||||
@@ -71,7 +73,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
@api.depends('processing_panel')
|
||||
def _compute_processing_panel_selection(self):
|
||||
for record in self:
|
||||
if record.processing_panel in ['ZM', 'FM', 'YC', 'QC']:
|
||||
if record.processing_panel in ['ZM', 'FM', 'YC', 'QC', 'HC', 'ZC']:
|
||||
record.processing_panel_selection = record.processing_panel
|
||||
else:
|
||||
record.processing_panel_selection = False
|
||||
@@ -1268,13 +1270,14 @@ class ResMrpWorkOrder(models.Model):
|
||||
# 生成工件配送单
|
||||
record.workpiece_delivery_ids = record._json_workpiece_delivery_list()
|
||||
if record.routing_type == 'CNC加工' or record.individuation_page_PTD is True:
|
||||
record.process_state = '待解除装夹'
|
||||
# record.write({'process_state': '待加工'})
|
||||
record.production_id.process_state = '待解除装夹'
|
||||
self.env['sf.production.plan'].sudo().search([('name', '=', record.production_id.name)]).write({
|
||||
'state': 'finished',
|
||||
'actual_end_time': datetime.now()
|
||||
})
|
||||
if record.routing_type == 'CNC加工':
|
||||
record.process_state = '待解除装夹'
|
||||
# record.write({'process_state': '待加工'})
|
||||
record.production_id.process_state = '待解除装夹'
|
||||
self.env['sf.production.plan'].sudo().search([('name', '=', record.production_id.name)]).write({
|
||||
'state': 'finished',
|
||||
'actual_end_time': datetime.now()
|
||||
})
|
||||
record.production_id.write({'detection_result_ids': [(0, 0, {
|
||||
'rework_reason': record.reason,
|
||||
'detailed_reason': record.detailed_reason,
|
||||
@@ -1363,7 +1366,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
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 == '合格':
|
||||
check_ids.write({'test_results': None})
|
||||
check_ids.write({'test_results': record.test_results})
|
||||
for check_id in check_ids:
|
||||
check_id.do_pass()
|
||||
elif record.test_results in ('返工', '报废'):
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
<tree position="attributes">
|
||||
<attribute name="multi_edit"></attribute>
|
||||
<attribute name="editable"></attribute>
|
||||
<attribute name="create">False</attribute>
|
||||
<attribute name="create">false</attribute>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -17,6 +17,7 @@ class QualityCheck(models.Model):
|
||||
('fail', '失败的')], string='状态', tracking=True, store=True,
|
||||
default='none', copy=False, compute='_compute_quality_state')
|
||||
|
||||
work_state = fields.Selection(related='workorder_id.state', string='工单状态')
|
||||
processing_panel = fields.Char(related='workorder_id.processing_panel', string='加工面')
|
||||
|
||||
production_line_id = fields.Many2one(related='workorder_id.production_line_id',
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
<field name="inherit_id" ref="quality_control.quality_check_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<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="model_file" widget="Viewer3D" string="模型" readonly="1" force_save="1"
|
||||
@@ -22,12 +24,14 @@
|
||||
<field name="detection_report" string="" widget="pdf_viewer"/>
|
||||
</page>
|
||||
<page string="判定结果" attrs="{'invisible': [('production_id', '=', False)]}">
|
||||
<group attrs="{'readonly': [('quality_state','in', ['pass', 'fail'])]}">
|
||||
<field name="test_results"/>
|
||||
<field name="reason"
|
||||
attrs="{'required': [('test_results','in', ['返工','报废'])],'invisible': [('test_results','in', ['合格',False])]}"/>
|
||||
<field name="detailed_reason"
|
||||
attrs="{'required': [('reason','!=', False)],'invisible': [('test_results','in', ['合格',False])]}"/>
|
||||
<group>
|
||||
<group>
|
||||
<field name="test_results" attrs="{'readonly': [('quality_state','in', ['pass', 'fail'])]}"/>
|
||||
<field name="reason"
|
||||
attrs="{'required': [('test_results','in', ['返工','报废'])],'invisible': [('test_results','in', ['合格',False])],'readonly': [('quality_state','in', ['pass', 'fail'])]}"/>
|
||||
<field name="detailed_reason"
|
||||
attrs="{'required': [('reason','!=', False)],'invisible': [('test_results','in', ['合格',False])],'readonly': [('quality_state','in', ['pass', 'fail'])]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
<page string="2D图纸" attrs="{'invisible': [('production_id', '=', False)]}">
|
||||
@@ -44,6 +48,12 @@
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//header//button[@name='do_pass'][2]" position="attributes">
|
||||
<attribute name="attrs">{'invisible': ['|',('quality_state', '!=', 'fail'),('work_state','=', 'done')]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//header//button[@name='do_fail'][2]" position="attributes">
|
||||
<attribute name="attrs">{'invisible': ['|',('quality_state', '!=', 'pass'),('work_state','=', 'done')]}</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -66,6 +76,10 @@
|
||||
<xpath expr="//field[@name='quality_state']" position="after">
|
||||
<field name="operation_id" icon="fa-filter" enable_counters="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='product_id']" position="after">
|
||||
<field name="production_id"/>
|
||||
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -371,15 +371,15 @@ class RePurchaseOrder(models.Model):
|
||||
pp.purchase_id = [(6, 0, [purchase_order.id])]
|
||||
# self.env.cr.commit()
|
||||
|
||||
@api.onchange('order_line')
|
||||
def _onchange_order_line(self):
|
||||
for order in self:
|
||||
if order.order_line:
|
||||
line = order.order_line
|
||||
product = line.product_id
|
||||
product_id = product.ids
|
||||
if len(product_id) != len(line):
|
||||
raise ValidationError('【%s】已存在,请勿重复添加' % product[-1].name)
|
||||
# @api.onchange('order_line')
|
||||
# def _onchange_order_line(self):
|
||||
# for order in self:
|
||||
# if order.order_line:
|
||||
# line = order.order_line
|
||||
# product = line.product_id
|
||||
# product_id = product.ids
|
||||
# if len(product_id) != len(line):
|
||||
# raise ValidationError('【%s】已存在,请勿重复添加' % product[-1].name)
|
||||
|
||||
def button_confirm(self):
|
||||
result = super(RePurchaseOrder, self).button_confirm()
|
||||
|
||||
@@ -285,7 +285,7 @@
|
||||
<tree position="attributes">
|
||||
<!-- <attribute name="default_order">schedule_status desc,date_order asc</attribute> -->
|
||||
<attribute name="default_order">create_date desc</attribute>
|
||||
<attribute name="create">False</attribute>
|
||||
<attribute name="create">false</attribute>
|
||||
<attribute name="decoration-warning">delivery_warning == 'warning'</attribute>
|
||||
<attribute name="decoration-danger">delivery_warning == 'overdue'</attribute>
|
||||
</tree>
|
||||
|
||||
Reference in New Issue
Block a user