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
|
||||
|
||||
from odoo import api, models, fields, _
|
||||
from odoo.api import depends
|
||||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT, float_round
|
||||
from odoo.osv.expression import OR
|
||||
|
||||
@@ -122,7 +123,13 @@ class QualityPoint(models.Model):
|
||||
|
||||
class QualityCheck(models.Model):
|
||||
_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)
|
||||
measure = fields.Float('Measure', default=0.0, digits='Quality Tests', tracking=True)
|
||||
measure_success = fields.Selection([
|
||||
|
||||
@@ -389,6 +389,8 @@
|
||||
<field name="name" decoration-bf="1"/>
|
||||
<field name="measure_on" 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_name" invisible="not context.get('show_lots_text')"/>
|
||||
<field name="picking_id" optional="hide" string="Transfer"/>
|
||||
|
||||
@@ -9,9 +9,9 @@ class StockRuleInherit(models.Model):
|
||||
@api.model
|
||||
def _run_buy(self, procurements):
|
||||
# 判断补货组的采购类型
|
||||
procurements_group = {'standard': [], 'consignment': []}
|
||||
procurements_group = {'standard': [], 'outsourcing': []}
|
||||
for procurement, rule in procurements:
|
||||
is_consignment = False
|
||||
is_outsourcing = False
|
||||
product = procurement.product_id
|
||||
# 获取主 BOM
|
||||
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:
|
||||
# print('route.name:', route.name)
|
||||
if route.name == '按订单补给外包商':
|
||||
is_consignment = True
|
||||
is_outsourcing = True
|
||||
|
||||
if is_consignment:
|
||||
procurements_group['consignment'].append((procurement, rule))
|
||||
if is_outsourcing:
|
||||
procurements_group['outsourcing'].append((procurement, rule))
|
||||
else:
|
||||
procurements_group['standard'].append((procurement, rule))
|
||||
|
||||
for key, value in procurements_group.items():
|
||||
super(StockRuleInherit, self)._run_buy(value)
|
||||
|
||||
if key == 'consignment':
|
||||
if key == 'outsourcing':
|
||||
for procurement, rule in value:
|
||||
supplier = procurement.values.get('supplier')
|
||||
if supplier:
|
||||
@@ -49,7 +49,7 @@ class StockRuleInherit(models.Model):
|
||||
], limit=1)
|
||||
logging.info("po=: %s", po)
|
||||
if po:
|
||||
po.write({'purchase_type': 'consignment'})
|
||||
po.write({'purchase_type': 'outsourcing'})
|
||||
|
||||
# # 首先调用父类的 _run_buy 方法,以保留原有逻辑
|
||||
# super(StockRuleInherit, self)._run_buy(procurements)
|
||||
@@ -83,5 +83,5 @@ class StockRuleInherit(models.Model):
|
||||
# ], limit=1)
|
||||
# logging.info("po=: %s", po)
|
||||
# if po:
|
||||
# po.write({'purchase_type': 'consignment'})
|
||||
# po.write({'purchase_type': 'outsourcing'})
|
||||
# break
|
||||
|
||||
@@ -363,15 +363,9 @@ class MrpProduction(models.Model):
|
||||
# if production.state == 'pending_cam':
|
||||
# if all(wo_state in 'done' for wo_state in production.workorder_ids.mapped('state')):
|
||||
# production.state = 'done'
|
||||
if any(
|
||||
(
|
||||
wo.test_results == '返工' and wo.state == 'done' and production.programming_state in [
|
||||
'已编程']) 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):
|
||||
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 ['编程中', '已编程'])
|
||||
for wo in production.workorder_ids):
|
||||
production.state = 'rework'
|
||||
if any(wo.test_results == '报废' and wo.state == 'done' for wo in production.workorder_ids):
|
||||
production.state = 'scrap'
|
||||
|
||||
@@ -31,3 +31,13 @@ class PurchaseOrder(models.Model):
|
||||
class PurchaseOrderLine(models.Model):
|
||||
_inherit = 'purchase.order.line'
|
||||
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 -*-
|
||||
from collections import Counter
|
||||
|
||||
from odoo import fields, models, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
@@ -6,7 +8,7 @@ from odoo.exceptions import ValidationError
|
||||
class sf_technology_design(models.Model):
|
||||
_name = 'sf.technology.design'
|
||||
_description = "工艺设计"
|
||||
|
||||
group_uniq_id = fields.Integer('同一制造订单唯一id',default=0)
|
||||
sequence = fields.Integer('序号')
|
||||
route_id = fields.Many2one('mrp.routing.workcenter', '工序')
|
||||
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)
|
||||
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):
|
||||
workorders_values_str = [0, '', {
|
||||
'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}]
|
||||
return workorders_values_str
|
||||
|
||||
def write(self, vals):
|
||||
print('qwfojkqwfkio')
|
||||
return super(sf_technology_design, self).write(vals)
|
||||
def unlink_technology_design(self):
|
||||
self.active = False
|
||||
|
||||
@@ -37,4 +47,64 @@ class sf_technology_design(models.Model):
|
||||
for vals in vals_list:
|
||||
if not vals.get('route_id'):
|
||||
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)]}"/>-->
|
||||
<button name="button_start" type="object" string="开始" class="btn-success" confirm="是否确认开始"
|
||||
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"
|
||||
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="是否确认完工"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="after">
|
||||
<field name="related_product" optional="show"/>
|
||||
<field name="part_number" optional="show"/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -10,7 +10,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
||||
|
||||
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||
origin = fields.Char(string='源单据')
|
||||
is_technology_re_adjust = fields.Boolean(default=False)
|
||||
is_technology_re_adjust = fields.Boolean(default=True)
|
||||
|
||||
def confirm(self):
|
||||
if self.is_technology_re_adjust is True:
|
||||
@@ -24,38 +24,39 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
||||
for production_item in productions:
|
||||
# 该制造订单的其他同一销售订单的制造订单的工艺设计处理
|
||||
if production_item != self.production_id:
|
||||
for td_other in production_item.technology_design_ids:
|
||||
if td_other.is_auto is False:
|
||||
td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
||||
if not td_del or td_del.active is False:
|
||||
td_other.write({'active': False})
|
||||
for td_main in technology_designs:
|
||||
route_other = production_item.technology_design_ids.filtered(
|
||||
lambda td: td.route_id.id == td_main.route_id.id)
|
||||
if not route_other and td_main.active is True:
|
||||
production_item.write({'technology_design_ids': [(0, 0, {
|
||||
'route_id': td_main.route_id.id,
|
||||
'process_parameters_id': False if td_main.process_parameters_id is False else
|
||||
self.env[
|
||||
'sf.production.process.parameter'].search(
|
||||
[('id', '=', td_main.process_parameters_id.id)]).id,
|
||||
'sequence': td_main.sequence,
|
||||
'is_auto': td_main.is_auto})]})
|
||||
else:
|
||||
for ro in route_other:
|
||||
domain = [('production_id', '=', self.production_id.id),
|
||||
('active', 'in', [True, False]),
|
||||
('route_id', '=', ro.route_id.id)]
|
||||
if ro.route_id.routing_type == '表面工艺':
|
||||
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
||||
elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
||||
# display_name = ro.route_id.display_name
|
||||
domain += [('id', '=', ro.id)]
|
||||
elif ro.panel is not False:
|
||||
domain += [('panel', '=', ro.panel)]
|
||||
td_upd = self.env['sf.technology.design'].sudo().search(domain)
|
||||
if td_upd:
|
||||
ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
|
||||
self.env['sf.technology.design'].sudo().unified_procedure_multiple_work_orders(technology_designs, production_item)
|
||||
# for td_other in production_item.technology_design_ids:
|
||||
# # if td_other.is_auto is False:
|
||||
# # td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
||||
# # if not td_del or td_del.active is False:
|
||||
# # td_other.write({'active': False})
|
||||
# for td_main in technology_designs:
|
||||
# route_other = production_item.technology_design_ids.filtered(
|
||||
# lambda td: td.route_id.id == td_main.route_id.id)
|
||||
# if not route_other and td_main.active is True:
|
||||
# production_item.write({'technology_design_ids': [(0, 0, {
|
||||
# 'route_id': td_main.route_id.id,
|
||||
# 'process_parameters_id': False if td_main.process_parameters_id is False else
|
||||
# self.env[
|
||||
# 'sf.production.process.parameter'].search(
|
||||
# [('id', '=', td_main.process_parameters_id.id)]).id,
|
||||
# 'sequence': td_main.sequence,
|
||||
# 'is_auto': td_main.is_auto})]})
|
||||
# else:
|
||||
# for ro in route_other:
|
||||
# domain = [('production_id', '=', self.production_id.id),
|
||||
# ('active', 'in', [True, False]),
|
||||
# ('route_id', '=', ro.route_id.id)]
|
||||
# if ro.route_id.routing_type == '表面工艺':
|
||||
# domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
||||
# elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
||||
# # display_name = ro.route_id.display_name
|
||||
# domain += [('id', '=', ro.id)]
|
||||
# elif ro.panel is not False:
|
||||
# domain += [('panel', '=', ro.panel)]
|
||||
# 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(
|
||||
[('routing_tag', '=', 'special'), ('production_id', '=', production_item.id),
|
||||
('is_auto', '=', False), ('active', 'in', [True, False])])
|
||||
@@ -124,3 +125,4 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
||||
if workorders[
|
||||
0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
|
||||
workorders[0].state = 'waiting'
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class ProductionTechnologyWizard(models.TransientModel):
|
||||
|
||||
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||
origin = fields.Char(string='源单据')
|
||||
is_technology_confirm = fields.Boolean(default=False)
|
||||
is_technology_confirm = fields.Boolean(default=True)
|
||||
|
||||
def confirm(self):
|
||||
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)]
|
||||
else:
|
||||
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)
|
||||
for production in productions:
|
||||
if production != self.production_id:
|
||||
for td_other in production.technology_design_ids:
|
||||
if td_other.is_auto is False:
|
||||
td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
||||
if not td_del or td_del.active is False:
|
||||
td_other.write({'active': False})
|
||||
for td_main in technology_designs:
|
||||
route_other = production.technology_design_ids.filtered(
|
||||
lambda td: td.route_id.id == td_main.route_id.id)
|
||||
if not route_other and td_main.active is True:
|
||||
production.write({'technology_design_ids': [(0, 0, {
|
||||
'route_id': td_main.route_id.id,
|
||||
'process_parameters_id': False if td_main.process_parameters_id is False else self.env[
|
||||
'sf.production.process.parameter'].search(
|
||||
[('id', '=', td_main.process_parameters_id.id)]).id,
|
||||
'sequence': td_main.sequence})]})
|
||||
else:
|
||||
for ro in route_other:
|
||||
domain = [('production_id', '=', self.production_id.id),
|
||||
('active', 'in', [True, False]),
|
||||
('route_id', '=', ro.route_id.id)]
|
||||
if ro.route_id.routing_type == '表面工艺':
|
||||
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
||||
elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
||||
# display_name = ro.route_id.display_name
|
||||
domain += [('id', '=', ro.id)]
|
||||
elif ro.panel is not False:
|
||||
domain += [('panel', '=', ro.panel)]
|
||||
td_upd = self.env['sf.technology.design'].sudo().search(domain)
|
||||
if td_upd:
|
||||
ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
|
||||
self.env['sf.technology.design'].sudo().unified_procedure_multiple_work_orders(technology_designs,
|
||||
production)
|
||||
# for td_other in production.technology_design_ids:
|
||||
# if td_other.is_auto is False:
|
||||
# td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
||||
# if not td_del or td_del.active is False:
|
||||
# td_other.write({'active': False})
|
||||
# for td_main in technology_designs:
|
||||
# route_other = production.technology_design_ids.filtered(
|
||||
# lambda td: td.route_id.id == td_main.route_id.id)
|
||||
# if not route_other and td_main.active is True:
|
||||
# production.write({'technology_design_ids': [(0, 0, {
|
||||
# 'route_id': td_main.route_id.id,
|
||||
# 'process_parameters_id': False if td_main.process_parameters_id is False else self.env[
|
||||
# 'sf.production.process.parameter'].search(
|
||||
# [('id', '=', td_main.process_parameters_id.id)]).id,
|
||||
# 'sequence': td_main.sequence})]})
|
||||
# else:
|
||||
# for ro in route_other:
|
||||
# domain = [('production_id', '=', self.production_id.id),
|
||||
# ('active', 'in', [True, False]),
|
||||
# ('route_id', '=', ro.route_id.id)]
|
||||
# if ro.route_id.routing_type == '表面工艺':
|
||||
# domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
||||
# elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
||||
# # display_name = ro.route_id.display_name
|
||||
# domain += [('id', '=', ro.id)]
|
||||
# elif ro.panel is not False:
|
||||
# domain += [('panel', '=', ro.panel)]
|
||||
# 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(
|
||||
[('routing_tag', '=', 'special'), ('production_id', '=', production.id),
|
||||
('is_auto', '=', False), ('active', 'in', [True, False])])
|
||||
|
||||
@@ -30,7 +30,7 @@ class SFMessageSale(models.Model):
|
||||
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
|
||||
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('委外加工采购单提醒')
|
||||
if purchase_order_id.purchase_type == 'standard':
|
||||
purchase_order_id.add_queue('外购订单采购单提醒')
|
||||
|
||||
@@ -16,7 +16,7 @@ class SfQualityCncTest(models.Model):
|
||||
equipment_id = fields.Many2one(related='workorder_id.equipment_id', string='加工设备')
|
||||
production_line_id = fields.Many2one(related='workorder_id.production_line_id',
|
||||
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='检测报告')
|
||||
state = fields.Selection([
|
||||
('waiting', '待判定'),
|
||||
|
||||
@@ -170,9 +170,9 @@ class ReSaleOrder(models.Model):
|
||||
def _compute_purchase_order_count(self):
|
||||
for order in self:
|
||||
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(
|
||||
lambda po: po.purchase_type in ['consignment']))
|
||||
lambda po: po.purchase_type in ['outsourcing']))
|
||||
|
||||
def action_view_purchase_orders(self):
|
||||
"""
|
||||
@@ -180,7 +180,7 @@ class ReSaleOrder(models.Model):
|
||||
"""
|
||||
self.ensure_one()
|
||||
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 = {
|
||||
'res_model': 'purchase.order',
|
||||
'type': 'ir.actions.act_window',
|
||||
@@ -203,21 +203,21 @@ class ReSaleOrder(models.Model):
|
||||
委外加工
|
||||
"""
|
||||
self.ensure_one()
|
||||
consignment_purchase_order_ids = self._get_purchase_orders().filtered(
|
||||
lambda po: po.purchase_type in ['consignment']).ids
|
||||
outsourcing_purchase_order_ids = self._get_purchase_orders().filtered(
|
||||
lambda po: po.purchase_type in ['outsourcing']).ids
|
||||
action = {
|
||||
'res_model': 'purchase.order',
|
||||
'type': 'ir.actions.act_window',
|
||||
}
|
||||
if len(consignment_purchase_order_ids) == 1:
|
||||
if len(outsourcing_purchase_order_ids) == 1:
|
||||
action.update({
|
||||
'view_mode': 'form',
|
||||
'res_id': consignment_purchase_order_ids[0],
|
||||
'res_id': outsourcing_purchase_order_ids[0],
|
||||
})
|
||||
else:
|
||||
action.update({
|
||||
'name': _("从 %s生成委外加工订单", self.name),
|
||||
'domain': [('id', 'in', consignment_purchase_order_ids)],
|
||||
'domain': [('id', 'in', outsourcing_purchase_order_ids)],
|
||||
'view_mode': 'tree,form',
|
||||
})
|
||||
return action
|
||||
@@ -400,11 +400,12 @@ class RePurchaseOrder(models.Model):
|
||||
move_id.put_move_line()
|
||||
for line in item.order_line:
|
||||
if line.product_id.categ_type == '表面工艺':
|
||||
for production_name in item.origin.split(','):
|
||||
production = self.env['mrp.production'].search([('name', '=', production_name)])
|
||||
for workorder in production.workorder_ids.filtered(
|
||||
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'
|
||||
if item.origin:
|
||||
for production_name in item.origin.split(','):
|
||||
production = self.env['mrp.production'].search([('name', '=', production_name)])
|
||||
for workorder in production.workorder_ids.filtered(
|
||||
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
|
||||
|
||||
@@ -416,7 +417,7 @@ class RePurchaseOrder(models.Model):
|
||||
last_overdue_order = None
|
||||
last_warning_order = None
|
||||
for item in purchase_order:
|
||||
current_time = datetime.now()
|
||||
current_time = datetime.datetime.now()
|
||||
if item.date_planned <= current_time: # 已逾期
|
||||
item.delivery_warning = 'overdue'
|
||||
last_overdue_order = item
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<button name="button_confirm" type="object" context="{'validate_analytic': True}"
|
||||
string="确认订单" id="draft_confirm"
|
||||
groups="sf_base.group_purchase,sf_base.group_purchase_director"
|
||||
attrs="{'invisible': [('state', 'in', ['purchase'])]}"
|
||||
attrs="{'invisible': [('state', 'in', ['purchase', 'cancel'])]}"
|
||||
/>
|
||||
</xpath>
|
||||
<xpath expr="//form/header/button[@name='action_rfq_send'][1]" position="replace">
|
||||
|
||||
@@ -45,7 +45,8 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
string='状态', store=True, default='正常')
|
||||
current_location_id = fields.Many2one('stock.location', string='当前位置', compute='_compute_current_location_id',
|
||||
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(
|
||||
[('组装后', '组装后'), ('刀具房', '刀具房'), ('线边刀库', '线边刀库'), ('机内刀库', '机内刀库')],
|
||||
string='位置', compute='_compute_current_location_id', store=True)
|
||||
@@ -85,6 +86,10 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
if quant_id.inventory_quantity_auto_apply > 0:
|
||||
record.current_location_id = quant_id.location_id
|
||||
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:
|
||||
record.current_location = '机内刀库'
|
||||
else:
|
||||
|
||||
@@ -888,12 +888,11 @@ class SfStockMoveLine(models.Model):
|
||||
def _check_destination_location_id(self):
|
||||
for item in self:
|
||||
if item:
|
||||
i = 0
|
||||
barcode = item.destination_location_id.barcode
|
||||
for line in item.picking_id.move_line_ids_without_package:
|
||||
if barcode and barcode == line.destination_location_id.barcode:
|
||||
i += 1
|
||||
if i > 1:
|
||||
if line.destination_location_id:
|
||||
if (barcode and barcode == line.destination_location_id.barcode
|
||||
and item.product_id != line.product_id):
|
||||
raise ValidationError(
|
||||
'【%s】货位已经被占用,请重新选择!!!' % item.destination_location_id.barcode)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user