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 = {}
|
product_group_id = {}
|
||||||
group_id = False
|
is_custemer_group_id = {} # 客供料与非客供料
|
||||||
is_first = False
|
|
||||||
for vals in vals_list:
|
for vals in vals_list:
|
||||||
if not vals.get('name', False) or vals['name'] == _('New'):
|
if not vals.get('name', False) or vals['name'] == _('New'):
|
||||||
picking_type_id = vals.get('picking_type_id')
|
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()
|
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'])
|
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_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_customer_provided = product_id.is_customer_provided
|
||||||
is_first = True
|
if not is_custemer_group_id.get(is_customer_provided):
|
||||||
group_id = self.env["procurement.group"].create({'name': vals.get('name')}).id
|
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 not vals.get('procurement_group_id'):
|
||||||
if product_id.product_tmpl_id.single_manufacturing:
|
if product_id.product_tmpl_id.single_manufacturing:
|
||||||
|
|
||||||
if product_id.categ_id.name == '成品' and is_self_process:
|
if product_id.categ_id.name == '成品' and is_self_process:
|
||||||
|
vals['procurement_group_id'] = is_custemer_group_id[is_customer_provided]
|
||||||
vals['procurement_group_id'] = group_id
|
|
||||||
continue
|
continue
|
||||||
if product_id.id not in product_group_id.keys():
|
if product_id.id not in product_group_id.keys():
|
||||||
procurement_group_vals = self._prepare_procurement_group_vals(vals)
|
procurement_group_vals = self._prepare_procurement_group_vals(vals)
|
||||||
@@ -1555,7 +1555,7 @@ class MrpProduction(models.Model):
|
|||||||
else:
|
else:
|
||||||
vals['procurement_group_id'] = product_group_id[product_id.id]
|
vals['procurement_group_id'] = product_group_id[product_id.id]
|
||||||
else:
|
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)
|
return super(MrpProduction, self).create(vals_list)
|
||||||
|
|
||||||
@api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id',
|
@api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id',
|
||||||
|
|||||||
@@ -44,7 +44,9 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
('ZM', 'ZM'),
|
('ZM', 'ZM'),
|
||||||
('FM', 'FM'),
|
('FM', 'FM'),
|
||||||
('YC', 'YC'),
|
('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='工序')
|
sequence = fields.Integer(string='工序')
|
||||||
routing_type = fields.Selection([
|
routing_type = fields.Selection([
|
||||||
('装夹预调', '装夹预调'),
|
('装夹预调', '装夹预调'),
|
||||||
@@ -71,7 +73,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
@api.depends('processing_panel')
|
@api.depends('processing_panel')
|
||||||
def _compute_processing_panel_selection(self):
|
def _compute_processing_panel_selection(self):
|
||||||
for record in 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
|
record.processing_panel_selection = record.processing_panel
|
||||||
else:
|
else:
|
||||||
record.processing_panel_selection = False
|
record.processing_panel_selection = False
|
||||||
@@ -1268,13 +1270,14 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# 生成工件配送单
|
# 生成工件配送单
|
||||||
record.workpiece_delivery_ids = record._json_workpiece_delivery_list()
|
record.workpiece_delivery_ids = record._json_workpiece_delivery_list()
|
||||||
if record.routing_type == 'CNC加工' or record.individuation_page_PTD is True:
|
if record.routing_type == 'CNC加工' or record.individuation_page_PTD is True:
|
||||||
record.process_state = '待解除装夹'
|
if record.routing_type == 'CNC加工':
|
||||||
# record.write({'process_state': '待加工'})
|
record.process_state = '待解除装夹'
|
||||||
record.production_id.process_state = '待解除装夹'
|
# record.write({'process_state': '待加工'})
|
||||||
self.env['sf.production.plan'].sudo().search([('name', '=', record.production_id.name)]).write({
|
record.production_id.process_state = '待解除装夹'
|
||||||
'state': 'finished',
|
self.env['sf.production.plan'].sudo().search([('name', '=', record.production_id.name)]).write({
|
||||||
'actual_end_time': datetime.now()
|
'state': 'finished',
|
||||||
})
|
'actual_end_time': datetime.now()
|
||||||
|
})
|
||||||
record.production_id.write({'detection_result_ids': [(0, 0, {
|
record.production_id.write({'detection_result_ids': [(0, 0, {
|
||||||
'rework_reason': record.reason,
|
'rework_reason': record.reason,
|
||||||
'detailed_reason': record.detailed_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')):
|
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'))
|
check_ids = record.check_ids.filtered(lambda qc: qc.quality_state in ('waiting', 'none'))
|
||||||
if record.test_results == '合格':
|
if record.test_results == '合格':
|
||||||
check_ids.write({'test_results': None})
|
check_ids.write({'test_results': record.test_results})
|
||||||
for check_id in check_ids:
|
for check_id in check_ids:
|
||||||
check_id.do_pass()
|
check_id.do_pass()
|
||||||
elif record.test_results in ('返工', '报废'):
|
elif record.test_results in ('返工', '报废'):
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
<tree position="attributes">
|
<tree position="attributes">
|
||||||
<attribute name="multi_edit"></attribute>
|
<attribute name="multi_edit"></attribute>
|
||||||
<attribute name="editable"></attribute>
|
<attribute name="editable"></attribute>
|
||||||
<attribute name="create">False</attribute>
|
<attribute name="create">false</attribute>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class QualityCheck(models.Model):
|
|||||||
('fail', '失败的')], string='状态', tracking=True, store=True,
|
('fail', '失败的')], string='状态', tracking=True, store=True,
|
||||||
default='none', copy=False, compute='_compute_quality_state')
|
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='加工面')
|
processing_panel = fields.Char(related='workorder_id.processing_panel', string='加工面')
|
||||||
|
|
||||||
production_line_id = fields.Many2one(related='workorder_id.production_line_id',
|
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="inherit_id" ref="quality_control.quality_check_view_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='alert_ids']" position="after">
|
<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="production_line_id" attrs="{'invisible': [('production_id', '=', False)]}"/>
|
||||||
<field name="equipment_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"
|
<field name="model_file" widget="Viewer3D" string="模型" readonly="1" force_save="1"
|
||||||
@@ -22,12 +24,14 @@
|
|||||||
<field name="detection_report" string="" widget="pdf_viewer"/>
|
<field name="detection_report" string="" widget="pdf_viewer"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="判定结果" attrs="{'invisible': [('production_id', '=', False)]}">
|
<page string="判定结果" attrs="{'invisible': [('production_id', '=', False)]}">
|
||||||
<group attrs="{'readonly': [('quality_state','in', ['pass', 'fail'])]}">
|
<group>
|
||||||
<field name="test_results"/>
|
<group>
|
||||||
<field name="reason"
|
<field name="test_results" attrs="{'readonly': [('quality_state','in', ['pass', 'fail'])]}"/>
|
||||||
attrs="{'required': [('test_results','in', ['返工','报废'])],'invisible': [('test_results','in', ['合格',False])]}"/>
|
<field name="reason"
|
||||||
<field name="detailed_reason"
|
attrs="{'required': [('test_results','in', ['返工','报废'])],'invisible': [('test_results','in', ['合格',False])],'readonly': [('quality_state','in', ['pass', 'fail'])]}"/>
|
||||||
attrs="{'required': [('reason','!=', False)],'invisible': [('test_results','in', ['合格',False])]}"/>
|
<field name="detailed_reason"
|
||||||
|
attrs="{'required': [('reason','!=', False)],'invisible': [('test_results','in', ['合格',False])],'readonly': [('quality_state','in', ['pass', 'fail'])]}"/>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
<page string="2D图纸" attrs="{'invisible': [('production_id', '=', False)]}">
|
<page string="2D图纸" attrs="{'invisible': [('production_id', '=', False)]}">
|
||||||
@@ -44,6 +48,12 @@
|
|||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</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>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -66,6 +76,10 @@
|
|||||||
<xpath expr="//field[@name='quality_state']" position="after">
|
<xpath expr="//field[@name='quality_state']" position="after">
|
||||||
<field name="operation_id" icon="fa-filter" enable_counters="1"/>
|
<field name="operation_id" icon="fa-filter" enable_counters="1"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath expr="//field[@name='product_id']" position="after">
|
||||||
|
<field name="production_id"/>
|
||||||
|
|
||||||
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -371,15 +371,15 @@ class RePurchaseOrder(models.Model):
|
|||||||
pp.purchase_id = [(6, 0, [purchase_order.id])]
|
pp.purchase_id = [(6, 0, [purchase_order.id])]
|
||||||
# self.env.cr.commit()
|
# self.env.cr.commit()
|
||||||
|
|
||||||
@api.onchange('order_line')
|
# @api.onchange('order_line')
|
||||||
def _onchange_order_line(self):
|
# def _onchange_order_line(self):
|
||||||
for order in self:
|
# for order in self:
|
||||||
if order.order_line:
|
# if order.order_line:
|
||||||
line = order.order_line
|
# line = order.order_line
|
||||||
product = line.product_id
|
# product = line.product_id
|
||||||
product_id = product.ids
|
# product_id = product.ids
|
||||||
if len(product_id) != len(line):
|
# if len(product_id) != len(line):
|
||||||
raise ValidationError('【%s】已存在,请勿重复添加' % product[-1].name)
|
# raise ValidationError('【%s】已存在,请勿重复添加' % product[-1].name)
|
||||||
|
|
||||||
def button_confirm(self):
|
def button_confirm(self):
|
||||||
result = super(RePurchaseOrder, self).button_confirm()
|
result = super(RePurchaseOrder, self).button_confirm()
|
||||||
|
|||||||
@@ -285,7 +285,7 @@
|
|||||||
<tree position="attributes">
|
<tree position="attributes">
|
||||||
<!-- <attribute name="default_order">schedule_status desc,date_order asc</attribute> -->
|
<!-- <attribute name="default_order">schedule_status desc,date_order asc</attribute> -->
|
||||||
<attribute name="default_order">create_date desc</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-warning">delivery_warning == 'warning'</attribute>
|
||||||
<attribute name="decoration-danger">delivery_warning == 'overdue'</attribute>
|
<attribute name="decoration-danger">delivery_warning == 'overdue'</attribute>
|
||||||
</tree>
|
</tree>
|
||||||
|
|||||||
Reference in New Issue
Block a user