Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造功能优化
This commit is contained in:
@@ -7,6 +7,7 @@ from datetime import datetime
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
from odoo import api, models, fields, _
|
from odoo import api, models, fields, _
|
||||||
|
from odoo.api import depends
|
||||||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT, float_round
|
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT, float_round
|
||||||
from odoo.osv.expression import OR
|
from odoo.osv.expression import OR
|
||||||
|
|
||||||
@@ -122,7 +123,13 @@ class QualityPoint(models.Model):
|
|||||||
|
|
||||||
class QualityCheck(models.Model):
|
class QualityCheck(models.Model):
|
||||||
_inherit = "quality.check"
|
_inherit = "quality.check"
|
||||||
|
part_name = fields.Char('零件名称', compute='_compute_part_name_number', readonly=True)
|
||||||
|
part_number = fields.Char('零件图号', compute='_compute_part_name_number', readonly=True)
|
||||||
|
@depends('product_id')
|
||||||
|
def _compute_part_name_number(self):
|
||||||
|
for record in self:
|
||||||
|
record.part_number = record.product_id.part_number
|
||||||
|
record.part_name = record.product_id.part_name
|
||||||
failure_message = fields.Html(related='point_id.failure_message', readonly=True)
|
failure_message = fields.Html(related='point_id.failure_message', readonly=True)
|
||||||
measure = fields.Float('Measure', default=0.0, digits='Quality Tests', tracking=True)
|
measure = fields.Float('Measure', default=0.0, digits='Quality Tests', tracking=True)
|
||||||
measure_success = fields.Selection([
|
measure_success = fields.Selection([
|
||||||
|
|||||||
@@ -389,6 +389,8 @@
|
|||||||
<field name="name" decoration-bf="1"/>
|
<field name="name" decoration-bf="1"/>
|
||||||
<field name="measure_on" optional="show"/>
|
<field name="measure_on" optional="show"/>
|
||||||
<field name='product_id' optional="show"/>
|
<field name='product_id' optional="show"/>
|
||||||
|
<field name="part_name" optional="hide"/>
|
||||||
|
<field name='part_number' optional="show"/>
|
||||||
<field name="lot_id" invisible="context.get('show_lots_text')"/>
|
<field name="lot_id" invisible="context.get('show_lots_text')"/>
|
||||||
<field name="lot_name" invisible="not context.get('show_lots_text')"/>
|
<field name="lot_name" invisible="not context.get('show_lots_text')"/>
|
||||||
<field name="picking_id" optional="hide" string="Transfer"/>
|
<field name="picking_id" optional="hide" string="Transfer"/>
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ class StockRuleInherit(models.Model):
|
|||||||
@api.model
|
@api.model
|
||||||
def _run_buy(self, procurements):
|
def _run_buy(self, procurements):
|
||||||
# 判断补货组的采购类型
|
# 判断补货组的采购类型
|
||||||
procurements_group = {'standard': [], 'consignment': []}
|
procurements_group = {'standard': [], 'outsourcing': []}
|
||||||
for procurement, rule in procurements:
|
for procurement, rule in procurements:
|
||||||
is_consignment = False
|
is_outsourcing = False
|
||||||
product = procurement.product_id
|
product = procurement.product_id
|
||||||
# 获取主 BOM
|
# 获取主 BOM
|
||||||
bom = self.env['mrp.bom'].search([('product_tmpl_id', '=', product.product_tmpl_id.id)], limit=1)
|
bom = self.env['mrp.bom'].search([('product_tmpl_id', '=', product.product_tmpl_id.id)], limit=1)
|
||||||
@@ -24,17 +24,17 @@ class StockRuleInherit(models.Model):
|
|||||||
for route in raw_material.route_ids:
|
for route in raw_material.route_ids:
|
||||||
# print('route.name:', route.name)
|
# print('route.name:', route.name)
|
||||||
if route.name == '按订单补给外包商':
|
if route.name == '按订单补给外包商':
|
||||||
is_consignment = True
|
is_outsourcing = True
|
||||||
|
|
||||||
if is_consignment:
|
if is_outsourcing:
|
||||||
procurements_group['consignment'].append((procurement, rule))
|
procurements_group['outsourcing'].append((procurement, rule))
|
||||||
else:
|
else:
|
||||||
procurements_group['standard'].append((procurement, rule))
|
procurements_group['standard'].append((procurement, rule))
|
||||||
|
|
||||||
for key, value in procurements_group.items():
|
for key, value in procurements_group.items():
|
||||||
super(StockRuleInherit, self)._run_buy(value)
|
super(StockRuleInherit, self)._run_buy(value)
|
||||||
|
|
||||||
if key == 'consignment':
|
if key == 'outsourcing':
|
||||||
for procurement, rule in value:
|
for procurement, rule in value:
|
||||||
supplier = procurement.values.get('supplier')
|
supplier = procurement.values.get('supplier')
|
||||||
if supplier:
|
if supplier:
|
||||||
@@ -49,7 +49,7 @@ class StockRuleInherit(models.Model):
|
|||||||
], limit=1)
|
], limit=1)
|
||||||
logging.info("po=: %s", po)
|
logging.info("po=: %s", po)
|
||||||
if po:
|
if po:
|
||||||
po.write({'purchase_type': 'consignment'})
|
po.write({'purchase_type': 'outsourcing'})
|
||||||
|
|
||||||
# # 首先调用父类的 _run_buy 方法,以保留原有逻辑
|
# # 首先调用父类的 _run_buy 方法,以保留原有逻辑
|
||||||
# super(StockRuleInherit, self)._run_buy(procurements)
|
# super(StockRuleInherit, self)._run_buy(procurements)
|
||||||
@@ -83,5 +83,5 @@ class StockRuleInherit(models.Model):
|
|||||||
# ], limit=1)
|
# ], limit=1)
|
||||||
# logging.info("po=: %s", po)
|
# logging.info("po=: %s", po)
|
||||||
# if po:
|
# if po:
|
||||||
# po.write({'purchase_type': 'consignment'})
|
# po.write({'purchase_type': 'outsourcing'})
|
||||||
# break
|
# break
|
||||||
|
|||||||
@@ -363,15 +363,9 @@ class MrpProduction(models.Model):
|
|||||||
# if production.state == 'pending_cam':
|
# if production.state == 'pending_cam':
|
||||||
# if all(wo_state in 'done' for wo_state in production.workorder_ids.mapped('state')):
|
# if all(wo_state in 'done' for wo_state in production.workorder_ids.mapped('state')):
|
||||||
# production.state = 'done'
|
# production.state = 'done'
|
||||||
if any(
|
if any((wo.test_results == '返工' and wo.state == 'done' and production.programming_state in ['已编程'])
|
||||||
(
|
or (wo.is_rework is True and wo.state == 'done' and production.programming_state in ['编程中', '已编程'])
|
||||||
wo.test_results == '返工' and wo.state == 'done' and production.programming_state in [
|
for wo in production.workorder_ids):
|
||||||
'已编程']) or (
|
|
||||||
wo.state == 'rework' and production.programming_state == '编程中') or (
|
|
||||||
wo.is_rework is True and wo.state == 'done' and production.programming_state in ['编程中',
|
|
||||||
'已编程'])
|
|
||||||
for wo in
|
|
||||||
production.workorder_ids):
|
|
||||||
production.state = 'rework'
|
production.state = 'rework'
|
||||||
if any(wo.test_results == '报废' and wo.state == 'done' for wo in production.workorder_ids):
|
if any(wo.test_results == '报废' and wo.state == 'done' for wo in production.workorder_ids):
|
||||||
production.state = 'scrap'
|
production.state = 'scrap'
|
||||||
|
|||||||
@@ -31,3 +31,13 @@ class PurchaseOrder(models.Model):
|
|||||||
class PurchaseOrderLine(models.Model):
|
class PurchaseOrderLine(models.Model):
|
||||||
_inherit = 'purchase.order.line'
|
_inherit = 'purchase.order.line'
|
||||||
part_number = fields.Char('零件图号', related='product_id.part_number', readonly=True)
|
part_number = fields.Char('零件图号', related='product_id.part_number', readonly=True)
|
||||||
|
related_product = fields.Many2one('product.product',compute='_compute_related_product', string='关联产品',help='经此产品工艺加工成的成品')
|
||||||
|
@api.depends('order_id.origin')
|
||||||
|
def _compute_related_product(self):
|
||||||
|
for record in self:
|
||||||
|
if record.product_id.detailed_type:
|
||||||
|
production_id = self.env['mrp.production'].search([('name', '=', record.order_id.origin)])
|
||||||
|
record.related_product = production_id.product_id if production_id else False
|
||||||
|
else:
|
||||||
|
record.related_product = False
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
from odoo import fields, models, api, _
|
from odoo import fields, models, api, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
@@ -6,7 +8,7 @@ from odoo.exceptions import ValidationError
|
|||||||
class sf_technology_design(models.Model):
|
class sf_technology_design(models.Model):
|
||||||
_name = 'sf.technology.design'
|
_name = 'sf.technology.design'
|
||||||
_description = "工艺设计"
|
_description = "工艺设计"
|
||||||
|
group_uniq_id = fields.Integer('同一制造订单唯一id',default=0)
|
||||||
sequence = fields.Integer('序号')
|
sequence = fields.Integer('序号')
|
||||||
route_id = fields.Many2one('mrp.routing.workcenter', '工序')
|
route_id = fields.Many2one('mrp.routing.workcenter', '工序')
|
||||||
process_parameters_id = fields.Many2one('sf.production.process.parameter', string='表面工艺参数')
|
process_parameters_id = fields.Many2one('sf.production.process.parameter', string='表面工艺参数')
|
||||||
@@ -17,6 +19,11 @@ class sf_technology_design(models.Model):
|
|||||||
is_auto = fields.Boolean('是否自动生成', default=False)
|
is_auto = fields.Boolean('是否自动生成', default=False)
|
||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
# @api.depends('production_id')
|
||||||
|
# def _compute_group_uniq_id(self):
|
||||||
|
# for record in self:
|
||||||
|
|
||||||
|
|
||||||
def json_technology_design_str(self, k, route, i, process_parameter):
|
def json_technology_design_str(self, k, route, i, process_parameter):
|
||||||
workorders_values_str = [0, '', {
|
workorders_values_str = [0, '', {
|
||||||
'route_id': route.id if route.routing_type in ['表面工艺'] else route.route_workcenter_id.id,
|
'route_id': route.id if route.routing_type in ['表面工艺'] else route.route_workcenter_id.id,
|
||||||
@@ -28,6 +35,9 @@ class sf_technology_design(models.Model):
|
|||||||
'is_auto': True}]
|
'is_auto': True}]
|
||||||
return workorders_values_str
|
return workorders_values_str
|
||||||
|
|
||||||
|
def write(self, vals):
|
||||||
|
print('qwfojkqwfkio')
|
||||||
|
return super(sf_technology_design, self).write(vals)
|
||||||
def unlink_technology_design(self):
|
def unlink_technology_design(self):
|
||||||
self.active = False
|
self.active = False
|
||||||
|
|
||||||
@@ -37,4 +47,64 @@ class sf_technology_design(models.Model):
|
|||||||
for vals in vals_list:
|
for vals in vals_list:
|
||||||
if not vals.get('route_id'):
|
if not vals.get('route_id'):
|
||||||
raise ValidationError(_("工序不能为空"))
|
raise ValidationError(_("工序不能为空"))
|
||||||
return super(sf_technology_design, self).create(vals_list)
|
result = super(sf_technology_design, self).create(vals_list)
|
||||||
|
for res in result:
|
||||||
|
record = self.search([('production_id', '=', res.production_id.id), ('active', 'in', [True, False])], order='group_uniq_id desc', limit=1)
|
||||||
|
res.group_uniq_id=record.group_uniq_id + 1
|
||||||
|
return result
|
||||||
|
def get_duplicates_with_inactive(self,technology_designs):
|
||||||
|
# 统计每个 'sequence' 出现的次数
|
||||||
|
sequence_count = Counter(technology_design.sequence for technology_design in technology_designs)
|
||||||
|
|
||||||
|
# 筛选出 'sequence' 重复且 'active' 为 False 的元素
|
||||||
|
result = [
|
||||||
|
technology_design for technology_design in technology_designs
|
||||||
|
if sequence_count[technology_design.sequence] > 1 and technology_design.active is False
|
||||||
|
]
|
||||||
|
|
||||||
|
return result
|
||||||
|
# def rearrange_numbering(self,self_technology_designs):
|
||||||
|
# inactive_designs = self.get_duplicates_with_inactive(self_technology_designs)
|
||||||
|
# if inactive_designs:
|
||||||
|
# max_design = max(self_technology_designs, key=lambda x: x.sequence)
|
||||||
|
# max_sequence = max_design.sequence if max_design else 0
|
||||||
|
# for designs in inactive_designs:
|
||||||
|
# max_sequence += 1
|
||||||
|
# designs.sequence = max_sequence
|
||||||
|
# self_technology_designs.sorted(key=lambda techology_design:techology_design.sequence)
|
||||||
|
# return self_technology_designs
|
||||||
|
|
||||||
|
def get_technology_design(self):
|
||||||
|
return {
|
||||||
|
'sequence':self.sequence,
|
||||||
|
'route_id': self.route_id.id,
|
||||||
|
'process_parameters_id': self.process_parameters_id.id,
|
||||||
|
'panel': self.panel,
|
||||||
|
'routing_tag': self.routing_tag,
|
||||||
|
'time_cycle_manual': self.time_cycle_manual,
|
||||||
|
'is_auto': self.is_auto,
|
||||||
|
'active': self.active,
|
||||||
|
'group_uniq_id':self.group_uniq_id,
|
||||||
|
}
|
||||||
|
def sync_technology_designs(self,production_technology_designs, self_technology_designs):
|
||||||
|
production_id = production_technology_designs[0].production_id.id
|
||||||
|
self_technology_design_dict = {item.group_uniq_id:item for item in self_technology_designs}
|
||||||
|
production_technology_designs_dict = {item.group_uniq_id:item for item in production_technology_designs}
|
||||||
|
for technology_design in production_technology_designs:
|
||||||
|
if not self_technology_design_dict.get(technology_design.group_uniq_id):
|
||||||
|
technology_design.write({'production_id': False})
|
||||||
|
else:
|
||||||
|
technology_design.write(self_technology_design_dict.get(technology_design.group_uniq_id).get_technology_design())
|
||||||
|
for technology_design in self_technology_designs:
|
||||||
|
if not production_technology_designs_dict.get(technology_design.group_uniq_id):
|
||||||
|
technology_design = technology_design.get_technology_design()
|
||||||
|
technology_design.update({'production_id': production_id})
|
||||||
|
technology_design.pop('group_uniq_id')
|
||||||
|
self.env['sf.technology.design'].create(technology_design)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def unified_procedure_multiple_work_orders(self,self_technology_designs,production_item):
|
||||||
|
technology_designs = self.env['sf.technology.design'].sudo().search(
|
||||||
|
[('production_id', '=', production_item.id), ('active', 'in', [True, False])])
|
||||||
|
self.sync_technology_designs(self_technology_designs=self_technology_designs,production_technology_designs=technology_designs)
|
||||||
@@ -174,8 +174,6 @@
|
|||||||
<!-- attrs="{'invisible': ['|', '|', '|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel','to be detected')), ('is_user_working', '!=', False)]}"/>-->
|
<!-- attrs="{'invisible': ['|', '|', '|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel','to be detected')), ('is_user_working', '!=', False)]}"/>-->
|
||||||
<button name="button_start" type="object" string="开始" class="btn-success" confirm="是否确认开始"
|
<button name="button_start" type="object" string="开始" class="btn-success" confirm="是否确认开始"
|
||||||
attrs="{'invisible': [('state', '!=', 'ready')]}"/>
|
attrs="{'invisible': [('state', '!=', 'ready')]}"/>
|
||||||
<button name="button_start" type="object" string="开始" class="btn-success"
|
|
||||||
attrs="{'invisible': [('state', '!=', 'ready')]}"/>
|
|
||||||
<button name="button_pending" type="object" string="暂停" class="btn-warning"
|
<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)]}"/>
|
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="是否确认完工"
|
<button name="button_finish" type="object" string="完成" class="btn-success" confirm="是否确认完工"
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="after">
|
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="after">
|
||||||
|
<field name="related_product" optional="show"/>
|
||||||
<field name="part_number" optional="show"/>
|
<field name="part_number" optional="show"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
|
|
||||||
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||||
origin = fields.Char(string='源单据')
|
origin = fields.Char(string='源单据')
|
||||||
is_technology_re_adjust = fields.Boolean(default=False)
|
is_technology_re_adjust = fields.Boolean(default=True)
|
||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.is_technology_re_adjust is True:
|
if self.is_technology_re_adjust is True:
|
||||||
@@ -24,38 +24,39 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
for production_item in productions:
|
for production_item in productions:
|
||||||
# 该制造订单的其他同一销售订单的制造订单的工艺设计处理
|
# 该制造订单的其他同一销售订单的制造订单的工艺设计处理
|
||||||
if production_item != self.production_id:
|
if production_item != self.production_id:
|
||||||
for td_other in production_item.technology_design_ids:
|
self.env['sf.technology.design'].sudo().unified_procedure_multiple_work_orders(technology_designs, production_item)
|
||||||
if td_other.is_auto is False:
|
# for td_other in production_item.technology_design_ids:
|
||||||
td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
# # if td_other.is_auto is False:
|
||||||
if not td_del or td_del.active is False:
|
# # td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
||||||
td_other.write({'active': False})
|
# # if not td_del or td_del.active is False:
|
||||||
for td_main in technology_designs:
|
# # td_other.write({'active': False})
|
||||||
route_other = production_item.technology_design_ids.filtered(
|
# for td_main in technology_designs:
|
||||||
lambda td: td.route_id.id == td_main.route_id.id)
|
# route_other = production_item.technology_design_ids.filtered(
|
||||||
if not route_other and td_main.active is True:
|
# lambda td: td.route_id.id == td_main.route_id.id)
|
||||||
production_item.write({'technology_design_ids': [(0, 0, {
|
# if not route_other and td_main.active is True:
|
||||||
'route_id': td_main.route_id.id,
|
# production_item.write({'technology_design_ids': [(0, 0, {
|
||||||
'process_parameters_id': False if td_main.process_parameters_id is False else
|
# 'route_id': td_main.route_id.id,
|
||||||
self.env[
|
# 'process_parameters_id': False if td_main.process_parameters_id is False else
|
||||||
'sf.production.process.parameter'].search(
|
# self.env[
|
||||||
[('id', '=', td_main.process_parameters_id.id)]).id,
|
# 'sf.production.process.parameter'].search(
|
||||||
'sequence': td_main.sequence,
|
# [('id', '=', td_main.process_parameters_id.id)]).id,
|
||||||
'is_auto': td_main.is_auto})]})
|
# 'sequence': td_main.sequence,
|
||||||
else:
|
# 'is_auto': td_main.is_auto})]})
|
||||||
for ro in route_other:
|
# else:
|
||||||
domain = [('production_id', '=', self.production_id.id),
|
# for ro in route_other:
|
||||||
('active', 'in', [True, False]),
|
# domain = [('production_id', '=', self.production_id.id),
|
||||||
('route_id', '=', ro.route_id.id)]
|
# ('active', 'in', [True, False]),
|
||||||
if ro.route_id.routing_type == '表面工艺':
|
# ('route_id', '=', ro.route_id.id)]
|
||||||
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
# if ro.route_id.routing_type == '表面工艺':
|
||||||
elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
# domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
||||||
# display_name = ro.route_id.display_name
|
# elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
||||||
domain += [('id', '=', ro.id)]
|
# # display_name = ro.route_id.display_name
|
||||||
elif ro.panel is not False:
|
# domain += [('id', '=', ro.id)]
|
||||||
domain += [('panel', '=', ro.panel)]
|
# elif ro.panel is not False:
|
||||||
td_upd = self.env['sf.technology.design'].sudo().search(domain)
|
# domain += [('panel', '=', ro.panel)]
|
||||||
if td_upd:
|
# td_upd = self.env['sf.technology.design'].sudo().search(domain)
|
||||||
ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
|
# if td_upd:
|
||||||
|
# ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
|
||||||
special_design = self.env['sf.technology.design'].sudo().search(
|
special_design = self.env['sf.technology.design'].sudo().search(
|
||||||
[('routing_tag', '=', 'special'), ('production_id', '=', production_item.id),
|
[('routing_tag', '=', 'special'), ('production_id', '=', production_item.id),
|
||||||
('is_auto', '=', False), ('active', 'in', [True, False])])
|
('is_auto', '=', False), ('active', 'in', [True, False])])
|
||||||
@@ -124,3 +125,4 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
if workorders[
|
if workorders[
|
||||||
0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
|
0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
|
||||||
workorders[0].state = 'waiting'
|
workorders[0].state = 'waiting'
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class ProductionTechnologyWizard(models.TransientModel):
|
|||||||
|
|
||||||
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||||
origin = fields.Char(string='源单据')
|
origin = fields.Char(string='源单据')
|
||||||
is_technology_confirm = fields.Boolean(default=False)
|
is_technology_confirm = fields.Boolean(default=True)
|
||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.is_technology_confirm is True and self.production_id.product_id.categ_id.type in ['成品', '坯料']:
|
if self.is_technology_confirm is True and self.production_id.product_id.categ_id.type in ['成品', '坯料']:
|
||||||
@@ -19,40 +19,44 @@ class ProductionTechnologyWizard(models.TransientModel):
|
|||||||
('product_id', '=', self.production_id.product_id.id)]
|
('product_id', '=', self.production_id.product_id.id)]
|
||||||
else:
|
else:
|
||||||
domain = [('id', '=', self.production_id.id)]
|
domain = [('id', '=', self.production_id.id)]
|
||||||
technology_designs = self.production_id.technology_design_ids
|
technology_designs = self.env['sf.technology.design'].sudo().search(
|
||||||
|
[('production_id', '=', self.production_id.id), ('active', 'in', [True, False])])
|
||||||
|
# technology_designs = self.production_id.technology_design_ids
|
||||||
productions = self.env['mrp.production'].search(domain)
|
productions = self.env['mrp.production'].search(domain)
|
||||||
for production in productions:
|
for production in productions:
|
||||||
if production != self.production_id:
|
if production != self.production_id:
|
||||||
for td_other in production.technology_design_ids:
|
self.env['sf.technology.design'].sudo().unified_procedure_multiple_work_orders(technology_designs,
|
||||||
if td_other.is_auto is False:
|
production)
|
||||||
td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
# for td_other in production.technology_design_ids:
|
||||||
if not td_del or td_del.active is False:
|
# if td_other.is_auto is False:
|
||||||
td_other.write({'active': False})
|
# td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
||||||
for td_main in technology_designs:
|
# if not td_del or td_del.active is False:
|
||||||
route_other = production.technology_design_ids.filtered(
|
# td_other.write({'active': False})
|
||||||
lambda td: td.route_id.id == td_main.route_id.id)
|
# for td_main in technology_designs:
|
||||||
if not route_other and td_main.active is True:
|
# route_other = production.technology_design_ids.filtered(
|
||||||
production.write({'technology_design_ids': [(0, 0, {
|
# lambda td: td.route_id.id == td_main.route_id.id)
|
||||||
'route_id': td_main.route_id.id,
|
# if not route_other and td_main.active is True:
|
||||||
'process_parameters_id': False if td_main.process_parameters_id is False else self.env[
|
# production.write({'technology_design_ids': [(0, 0, {
|
||||||
'sf.production.process.parameter'].search(
|
# 'route_id': td_main.route_id.id,
|
||||||
[('id', '=', td_main.process_parameters_id.id)]).id,
|
# 'process_parameters_id': False if td_main.process_parameters_id is False else self.env[
|
||||||
'sequence': td_main.sequence})]})
|
# 'sf.production.process.parameter'].search(
|
||||||
else:
|
# [('id', '=', td_main.process_parameters_id.id)]).id,
|
||||||
for ro in route_other:
|
# 'sequence': td_main.sequence})]})
|
||||||
domain = [('production_id', '=', self.production_id.id),
|
# else:
|
||||||
('active', 'in', [True, False]),
|
# for ro in route_other:
|
||||||
('route_id', '=', ro.route_id.id)]
|
# domain = [('production_id', '=', self.production_id.id),
|
||||||
if ro.route_id.routing_type == '表面工艺':
|
# ('active', 'in', [True, False]),
|
||||||
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
# ('route_id', '=', ro.route_id.id)]
|
||||||
elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
# if ro.route_id.routing_type == '表面工艺':
|
||||||
# display_name = ro.route_id.display_name
|
# domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
||||||
domain += [('id', '=', ro.id)]
|
# elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
||||||
elif ro.panel is not False:
|
# # display_name = ro.route_id.display_name
|
||||||
domain += [('panel', '=', ro.panel)]
|
# domain += [('id', '=', ro.id)]
|
||||||
td_upd = self.env['sf.technology.design'].sudo().search(domain)
|
# elif ro.panel is not False:
|
||||||
if td_upd:
|
# domain += [('panel', '=', ro.panel)]
|
||||||
ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
|
# td_upd = self.env['sf.technology.design'].sudo().search(domain)
|
||||||
|
# if td_upd:
|
||||||
|
# ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
|
||||||
special_design = self.env['sf.technology.design'].sudo().search(
|
special_design = self.env['sf.technology.design'].sudo().search(
|
||||||
[('routing_tag', '=', 'special'), ('production_id', '=', production.id),
|
[('routing_tag', '=', 'special'), ('production_id', '=', production.id),
|
||||||
('is_auto', '=', False), ('active', 'in', [True, False])])
|
('is_auto', '=', False), ('active', 'in', [True, False])])
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class SFMessageSale(models.Model):
|
|||||||
purchase_order_info.add_queue('坯料采购提醒')
|
purchase_order_info.add_queue('坯料采购提醒')
|
||||||
purchase_order_ids = self.order_line.purchase_line_ids.order_id | self.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | self.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id
|
purchase_order_ids = self.order_line.purchase_line_ids.order_id | self.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | self.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id
|
||||||
for purchase_order_id in purchase_order_ids:
|
for purchase_order_id in purchase_order_ids:
|
||||||
if purchase_order_id.purchase_type == 'consignment':
|
if purchase_order_id.purchase_type == 'outsourcing':
|
||||||
purchase_order_id.add_queue('委外加工采购单提醒')
|
purchase_order_id.add_queue('委外加工采购单提醒')
|
||||||
if purchase_order_id.purchase_type == 'standard':
|
if purchase_order_id.purchase_type == 'standard':
|
||||||
purchase_order_id.add_queue('外购订单采购单提醒')
|
purchase_order_id.add_queue('外购订单采购单提醒')
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class SfQualityCncTest(models.Model):
|
|||||||
equipment_id = fields.Many2one(related='workorder_id.equipment_id', string='加工设备')
|
equipment_id = fields.Many2one(related='workorder_id.equipment_id', string='加工设备')
|
||||||
production_line_id = fields.Many2one(related='workorder_id.production_line_id',
|
production_line_id = fields.Many2one(related='workorder_id.production_line_id',
|
||||||
string='生产线')
|
string='生产线')
|
||||||
part_number = fields.Char(related='workorder_id.part_number', string='成品零件图号')
|
part_number = fields.Char(related='workorder_id.part_number', string='零件图号')
|
||||||
detection_report = fields.Binary(related='workorder_id.detection_report', readonly=True, string='检测报告')
|
detection_report = fields.Binary(related='workorder_id.detection_report', readonly=True, string='检测报告')
|
||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
('waiting', '待判定'),
|
('waiting', '待判定'),
|
||||||
|
|||||||
@@ -170,9 +170,9 @@ class ReSaleOrder(models.Model):
|
|||||||
def _compute_purchase_order_count(self):
|
def _compute_purchase_order_count(self):
|
||||||
for order in self:
|
for order in self:
|
||||||
order.purchase_order_count = len(order._get_purchase_orders().filtered(
|
order.purchase_order_count = len(order._get_purchase_orders().filtered(
|
||||||
lambda po: po.purchase_type not in ['consignment']))
|
lambda po: po.purchase_type not in ['outsourcing']))
|
||||||
order.consignment_purchase_order_count = len(order._get_purchase_orders().filtered(
|
order.consignment_purchase_order_count = len(order._get_purchase_orders().filtered(
|
||||||
lambda po: po.purchase_type in ['consignment']))
|
lambda po: po.purchase_type in ['outsourcing']))
|
||||||
|
|
||||||
def action_view_purchase_orders(self):
|
def action_view_purchase_orders(self):
|
||||||
"""
|
"""
|
||||||
@@ -180,7 +180,7 @@ class ReSaleOrder(models.Model):
|
|||||||
"""
|
"""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
purchase_order_ids = self._get_purchase_orders().filtered(
|
purchase_order_ids = self._get_purchase_orders().filtered(
|
||||||
lambda po: po.purchase_type not in ['consignment']).ids
|
lambda po: po.purchase_type not in ['outsourcing']).ids
|
||||||
action = {
|
action = {
|
||||||
'res_model': 'purchase.order',
|
'res_model': 'purchase.order',
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
@@ -203,21 +203,21 @@ class ReSaleOrder(models.Model):
|
|||||||
委外加工
|
委外加工
|
||||||
"""
|
"""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
consignment_purchase_order_ids = self._get_purchase_orders().filtered(
|
outsourcing_purchase_order_ids = self._get_purchase_orders().filtered(
|
||||||
lambda po: po.purchase_type in ['consignment']).ids
|
lambda po: po.purchase_type in ['outsourcing']).ids
|
||||||
action = {
|
action = {
|
||||||
'res_model': 'purchase.order',
|
'res_model': 'purchase.order',
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
}
|
}
|
||||||
if len(consignment_purchase_order_ids) == 1:
|
if len(outsourcing_purchase_order_ids) == 1:
|
||||||
action.update({
|
action.update({
|
||||||
'view_mode': 'form',
|
'view_mode': 'form',
|
||||||
'res_id': consignment_purchase_order_ids[0],
|
'res_id': outsourcing_purchase_order_ids[0],
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
action.update({
|
action.update({
|
||||||
'name': _("从 %s生成委外加工订单", self.name),
|
'name': _("从 %s生成委外加工订单", self.name),
|
||||||
'domain': [('id', 'in', consignment_purchase_order_ids)],
|
'domain': [('id', 'in', outsourcing_purchase_order_ids)],
|
||||||
'view_mode': 'tree,form',
|
'view_mode': 'tree,form',
|
||||||
})
|
})
|
||||||
return action
|
return action
|
||||||
@@ -400,11 +400,12 @@ class RePurchaseOrder(models.Model):
|
|||||||
move_id.put_move_line()
|
move_id.put_move_line()
|
||||||
for line in item.order_line:
|
for line in item.order_line:
|
||||||
if line.product_id.categ_type == '表面工艺':
|
if line.product_id.categ_type == '表面工艺':
|
||||||
for production_name in item.origin.split(','):
|
if item.origin:
|
||||||
production = self.env['mrp.production'].search([('name', '=', production_name)])
|
for production_name in item.origin.split(','):
|
||||||
for workorder in production.workorder_ids.filtered(
|
production = self.env['mrp.production'].search([('name', '=', production_name)])
|
||||||
lambda wd: wd.routing_type == '表面工艺' and wd.state == 'waiting' and line.product_id.server_product_process_parameters_id == wd.surface_technics_parameters_id):
|
for workorder in production.workorder_ids.filtered(
|
||||||
workorder.state = 'ready'
|
lambda wd: wd.routing_type == '表面工艺' and wd.state == 'waiting' and line.product_id.server_product_process_parameters_id == wd.surface_technics_parameters_id):
|
||||||
|
workorder.state = 'ready'
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -416,7 +417,7 @@ class RePurchaseOrder(models.Model):
|
|||||||
last_overdue_order = None
|
last_overdue_order = None
|
||||||
last_warning_order = None
|
last_warning_order = None
|
||||||
for item in purchase_order:
|
for item in purchase_order:
|
||||||
current_time = datetime.now()
|
current_time = datetime.datetime.now()
|
||||||
if item.date_planned <= current_time: # 已逾期
|
if item.date_planned <= current_time: # 已逾期
|
||||||
item.delivery_warning = 'overdue'
|
item.delivery_warning = 'overdue'
|
||||||
last_overdue_order = item
|
last_overdue_order = item
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
<button name="button_confirm" type="object" context="{'validate_analytic': True}"
|
<button name="button_confirm" type="object" context="{'validate_analytic': True}"
|
||||||
string="确认订单" id="draft_confirm"
|
string="确认订单" id="draft_confirm"
|
||||||
groups="sf_base.group_purchase,sf_base.group_purchase_director"
|
groups="sf_base.group_purchase,sf_base.group_purchase_director"
|
||||||
attrs="{'invisible': [('state', 'in', ['purchase'])]}"
|
attrs="{'invisible': [('state', 'in', ['purchase', 'cancel'])]}"
|
||||||
/>
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//form/header/button[@name='action_rfq_send'][1]" position="replace">
|
<xpath expr="//form/header/button[@name='action_rfq_send'][1]" position="replace">
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
string='状态', store=True, default='正常')
|
string='状态', store=True, default='正常')
|
||||||
current_location_id = fields.Many2one('stock.location', string='当前位置', compute='_compute_current_location_id',
|
current_location_id = fields.Many2one('stock.location', string='当前位置', compute='_compute_current_location_id',
|
||||||
store=True)
|
store=True)
|
||||||
current_shelf_location_id = fields.Many2one('sf.shelf.location', string='当前货位', readonly=True)
|
current_shelf_location_id = fields.Many2one('sf.shelf.location', string='当前货位',
|
||||||
|
compute='_compute_current_location_id', store=True)
|
||||||
current_location = fields.Selection(
|
current_location = fields.Selection(
|
||||||
[('组装后', '组装后'), ('刀具房', '刀具房'), ('线边刀库', '线边刀库'), ('机内刀库', '机内刀库')],
|
[('组装后', '组装后'), ('刀具房', '刀具房'), ('线边刀库', '线边刀库'), ('机内刀库', '机内刀库')],
|
||||||
string='位置', compute='_compute_current_location_id', store=True)
|
string='位置', compute='_compute_current_location_id', store=True)
|
||||||
@@ -85,6 +86,10 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
if quant_id.inventory_quantity_auto_apply > 0:
|
if quant_id.inventory_quantity_auto_apply > 0:
|
||||||
record.current_location_id = quant_id.location_id
|
record.current_location_id = quant_id.location_id
|
||||||
if quant_id.location_id.name == '制造前':
|
if quant_id.location_id.name == '制造前':
|
||||||
|
shelf_location_id = self.env['sf.shelf.location'].sudo().search([
|
||||||
|
('product_sn_id', '=', record.barcode_id.id)])
|
||||||
|
if shelf_location_id:
|
||||||
|
record.current_shelf_location_id = shelf_location_id.id
|
||||||
if not record.current_shelf_location_id:
|
if not record.current_shelf_location_id:
|
||||||
record.current_location = '机内刀库'
|
record.current_location = '机内刀库'
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -888,12 +888,11 @@ class SfStockMoveLine(models.Model):
|
|||||||
def _check_destination_location_id(self):
|
def _check_destination_location_id(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
if item:
|
if item:
|
||||||
i = 0
|
|
||||||
barcode = item.destination_location_id.barcode
|
barcode = item.destination_location_id.barcode
|
||||||
for line in item.picking_id.move_line_ids_without_package:
|
for line in item.picking_id.move_line_ids_without_package:
|
||||||
if barcode and barcode == line.destination_location_id.barcode:
|
if line.destination_location_id:
|
||||||
i += 1
|
if (barcode and barcode == line.destination_location_id.barcode
|
||||||
if i > 1:
|
and item.product_id != line.product_id):
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
'【%s】货位已经被占用,请重新选择!!!' % item.destination_location_id.barcode)
|
'【%s】货位已经被占用,请重新选择!!!' % item.destination_location_id.barcode)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user