diff --git a/mrp_workorder/views/mrp_workorder_views.xml b/mrp_workorder/views/mrp_workorder_views.xml
index 8c208f19..eba33155 100644
--- a/mrp_workorder/views/mrp_workorder_views.xml
+++ b/mrp_workorder/views/mrp_workorder_views.xml
@@ -138,7 +138,7 @@ if env.user.has_group('mrp.group_mrp_workorder_dependencies'):
-
+
diff --git a/sf_bf_connect/models/jd_eclp.py b/sf_bf_connect/models/jd_eclp.py
index 58691ca0..aa27736c 100644
--- a/sf_bf_connect/models/jd_eclp.py
+++ b/sf_bf_connect/models/jd_eclp.py
@@ -151,6 +151,12 @@ class JdEclp(models.Model):
_logger.info('准备调接口1')
url1 = config['bfm_url_new'] + '/api/create/jd/order'
requests.post(url1, json=json1, data=None)
+ # ===============修改销售订单状态为【物流中】===================
+ item = self.env['sale.order'].sudo().search([('name', '=', self.origin)])
+ if not item:
+ raise ValidationError('没有查询到订单号为【%s】的销售订单!' % self.origin)
+ else:
+ item.write({'state': 'physical_distribution'})
_logger.info('调用成功1')
_logger.info('准备调接口2')
json2 = {
diff --git a/sf_manufacturing/models/__init__.py b/sf_manufacturing/models/__init__.py
index 9f77d841..c4d8ad94 100644
--- a/sf_manufacturing/models/__init__.py
+++ b/sf_manufacturing/models/__init__.py
@@ -15,3 +15,4 @@ from . import sf_technology_design
from . import sf_production_common
from . import sale_order
from . import quick_easy_order
+from . import purchase_order
\ No newline at end of file
diff --git a/sf_manufacturing/models/model_type.py b/sf_manufacturing/models/model_type.py
index 1fe36b90..601c34e8 100644
--- a/sf_manufacturing/models/model_type.py
+++ b/sf_manufacturing/models/model_type.py
@@ -75,7 +75,7 @@ class ManualProductModelTypeRoutingSort(models.Model):
_description = '成品工序排序(人工线下加工)'
sequence = fields.Integer('Sequence')
- route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
+ route_workcenter_id = fields.Many2one('mrp.routing.workcenter', domain=[('routing_type', 'in', ['人工线下加工'])])
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type')
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py
index 07438afb..d440d5bc 100644
--- a/sf_manufacturing/models/mrp_production.py
+++ b/sf_manufacturing/models/mrp_production.py
@@ -440,6 +440,18 @@ class MrpProduction(models.Model):
process_parameters = []
account_moves = []
parameters_not = []
+ # 获取原有的工单对应的工序
+ origin_designs = self.workorder_ids.technology_design_id
+ # 获取已删除的工序
+ deleted_designs = origin_designs - self.technology_design_ids
+ if deleted_designs:
+ for deleted_design in deleted_designs:
+ workorder = self.env['mrp.workorder'].search([('technology_design_id', '=', deleted_design.id)])
+ purchase = workorder._get_surface_technics_purchase_ids()
+ account = self.env['account.move'].search([('id', 'in', purchase.invoice_ids.ids)])
+ if account.state not in ['cancel', False]:
+ if purchase.name not in account_moves:
+ account_moves.append(purchase.name)
special_design = self.technology_design_ids.filtered(
lambda a: a.routing_tag == 'special' and a.is_auto is False)
for special in special_design:
@@ -451,11 +463,7 @@ class MrpProduction(models.Model):
if not product_production_process:
if special.process_parameters_id not in process_parameters:
process_parameters.append(special.process_parameters_id.display_name)
- purchase = self.env['purchase.order'].search([('origin', '=', special.production_id.name)])
- account = self.env['account.move'].search([('id', 'in', purchase.invoice_ids)])
- if account.state not in ['cancel', False]:
- if purchase.name not in account_moves:
- account_moves.append(purchase.name)
+
if account_moves:
raise UserError(_("请联系工厂生产经理对采购订单为%s生成的账单进行取消", ", ".join(account_moves)))
if parameters_not:
diff --git a/sf_manufacturing/models/mrp_routing_workcenter.py b/sf_manufacturing/models/mrp_routing_workcenter.py
index e28bd091..27c8e9d2 100644
--- a/sf_manufacturing/models/mrp_routing_workcenter.py
+++ b/sf_manufacturing/models/mrp_routing_workcenter.py
@@ -94,4 +94,10 @@ class ResMrpRoutingWorkcenter(models.Model):
route_ids.append(t.route_id.surface_technics_id.id)
domain = [('id', 'not in', route_ids), ('routing_tag', '=', 'special')]
return self._search(domain, limit=limit, access_rights_uid=name_get_uid)
+ if self._context.get('is_duplicate') and self._context.get('model_name'):
+ # 查询出已经选择的工序
+ model_type = self.env[self._context.get('model_name')].search_read([],['route_workcenter_id'])
+ route_workcenter_ids = [item['route_workcenter_id'][0] if item['route_workcenter_id'] else False for item in model_type]
+ domain = args + [('id', 'not in', route_workcenter_ids)]
+ return self._search(domain, limit=limit, access_rights_uid=name_get_uid)
return super()._name_search(name, args, operator, limit, name_get_uid)
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index bcc3aafd..52fa30c8 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -1114,9 +1114,7 @@ class ResMrpWorkOrder(models.Model):
# ================= 如果制造订单刀具状态为[无效刀、缺刀] 或者 制造订单状态为[返工]==========================
if (workorder.production_id.tool_state in ['1', '2'] or workorder.production_id.state == 'rework'
or workorder.production_id.schedule_state != '已排'
- or workorder.production_id.reservation_state not in ['assigned']
- or workorder.production_id.workorder_ids.filtered(
- lambda wk: wk.sequence == workorder.sequence - 1).test_results in ['报废', '返工']):
+ or workorder.production_id.reservation_state not in ['assigned']):
if workorder.state != 'waiting':
workorder.state = 'waiting'
continue
@@ -1425,8 +1423,7 @@ class ResMrpWorkOrder(models.Model):
len(done_workorder) == len(record.production_id.workorder_ids)):
is_production_id = True
if record.routing_type in ['解除装夹'] or (
- record.is_rework is True and record.routing_type in ['装夹预调']) or (
- record.test_results in ['返工', '报废'] and record.routing_type in ['CNC加工']):
+ record.is_rework is True and record.routing_type in ['装夹预调']):
for workorder in record.production_id.workorder_ids:
if workorder.processing_panel == record.processing_panel:
rfid_code = workorder.rfid_code
diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py
new file mode 100644
index 00000000..e54e96bf
--- /dev/null
+++ b/sf_manufacturing/models/purchase_order.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from collections import defaultdict
+
+from odoo import api, fields, models, _
+from odoo.tools import OrderedSet
+
+
+# _get_surface_technics_purchase_ids
+class PurchaseOrder(models.Model):
+ _inherit = 'purchase.order'
+
+ def button_confirm(self):
+ super().button_confirm()
+ workorders = self.env['mrp.workorder'].search([('purchase_id', '=', self.id)])
+ for workorder in workorders:
+ if workorder.routing_type == '表面工艺' and workorder.is_subcontract is True:
+ move_out = workorder.move_subcontract_workorder_ids[1]
+ # move_out = self.env['stock.move'].search(
+ # [('location_id', '=', self.env['stock.location'].search(
+ # [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
+ # ('location_dest_id', '=', self.env['stock.location'].search(
+ # [('barcode', 'ilike', 'VL-SPOC')]).id),
+ # ('origin', '=', self.production_id.name), ('state', 'not in', ['cancel', 'done'])])
+ for mo in move_out:
+ if mo.state != 'done':
+ mo.write({'state': 'assigned', 'production_id': False})
+ if not mo.move_line_ids:
+ self.env['stock.move.line'].create(mo.get_move_line(workorder.production_id, workorder))
+ return True
diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py
index 710d9abb..d776c168 100644
--- a/sf_manufacturing/models/stock.py
+++ b/sf_manufacturing/models/stock.py
@@ -656,12 +656,19 @@ class StockPicking(models.Model):
workorder = move_in.subcontract_workorder_id
workorders = workorder.production_id.workorder_ids
subcontract_workorders = workorders.filtered(lambda wo: wo.is_subcontract == True).sorted('sequence')
- if workorder == subcontract_workorders[-1]:
+ if workorder == subcontract_workorders[-1]:
self.env['stock.quant']._update_reserved_quantity(
- move_in.product_id, move_in.location_dest_id, move_in.product_uom_qty, lot_id=move_in.move_line_ids.lot_id,
+ move_in.product_id, move_in.location_dest_id, move_in.product_uom_qty,
+ lot_id=move_in.move_line_ids.lot_id,
package_id=False, owner_id=False, strict=False
)
-
+ workorder.button_finish()
+ picking_type_out = self.env.ref('sf_manufacturing.outcontract_picking_out').id
+ if res and self.picking_type_id.id == picking_type_out:
+ move_out = self.move_ids
+ if move_out:
+ workorder = move_out.subcontract_workorder_id
+ workorder.button_start()
return res
# 创建 外协出库入单
@@ -683,14 +690,16 @@ class StockPicking(models.Model):
else:
# 从sorted_workorders中找到上一工单的move
if sorted_workorders.index(workorder) > 0:
- move_dest_id = sorted_workorders[sorted_workorders.index(workorder) - 1].move_subcontract_workorder_ids[1].id
+ move_dest_id = \
+ sorted_workorders[sorted_workorders.index(workorder) - 1].move_subcontract_workorder_ids[1].id
new_picking = True
outcontract_picking_type_in = self.env.ref(
'sf_manufacturing.outcontract_picking_in').id,
outcontract_picking_type_out = self.env.ref(
'sf_manufacturing.outcontract_picking_out').id,
moves_in = self.env['stock.move'].sudo().create(
- self.env['stock.move']._get_stock_move_values_Res(item, outcontract_picking_type_in, procurement_group_id.id, move_dest_id))
+ self.env['stock.move']._get_stock_move_values_Res(item, outcontract_picking_type_in,
+ procurement_group_id.id, move_dest_id))
picking_in = self.create(
moves_in._get_new_picking_values_Res(item, workorder, 'WH/OCIN/'))
# pick_ids.append(picking_in.id)
@@ -698,7 +707,8 @@ class StockPicking(models.Model):
{'picking_id': picking_in.id, 'state': 'waiting'})
moves_in._assign_picking_post_process(new=new_picking)
moves_out = self.env['stock.move'].sudo().create(
- self.env['stock.move']._get_stock_move_values_Res(item, outcontract_picking_type_out, procurement_group_id.id, moves_in.id))
+ self.env['stock.move']._get_stock_move_values_Res(item, outcontract_picking_type_out,
+ procurement_group_id.id, moves_in.id))
workorder.write({'move_subcontract_workorder_ids': [(6, 0, [moves_in.id, moves_out.id])]})
picking_out = self.create(
moves_out._get_new_picking_values_Res(item, workorder, 'WH/OCOUT/'))
@@ -706,8 +716,7 @@ class StockPicking(models.Model):
moves_out.write(
{'picking_id': picking_out.id, 'state': 'waiting'})
moves_out._assign_picking_post_process(new=new_picking)
-
-
+
@api.depends('move_type', 'immediate_transfer', 'move_ids.state', 'move_ids.picking_id')
def _compute_state(self):
super(StockPicking, self)._compute_state()
@@ -718,7 +727,9 @@ class StockPicking(models.Model):
if picking.move_ids:
workorder = picking.move_ids[0].subcontract_workorder_id
if picking.state == 'assigned':
- if workorder.state in ['pending', 'waiting'] or workorder._get_surface_technics_purchase_ids().state in ['draft', 'sent']:
+ if workorder.state in ['pending',
+ 'waiting'] or workorder._get_surface_technics_purchase_ids().state in [
+ 'draft', 'sent']:
picking.state = 'waiting'
@@ -731,7 +742,8 @@ class ReStockMove(models.Model):
def _get_stock_move_values_Res(self, item, picking_type_id, group_id, move_dest_ids=False):
route_id = self.env.ref('sf_manufacturing.route_surface_technology_outsourcing').id
- stock_rule = self.env['stock.rule'].sudo().search([('route_id', '=', route_id), ('picking_type_id', '=', picking_type_id)])
+ stock_rule = self.env['stock.rule'].sudo().search(
+ [('route_id', '=', route_id), ('picking_type_id', '=', picking_type_id)])
move_values = {
'name': '推',
'company_id': item.company_id.id,
@@ -1009,8 +1021,9 @@ class ReStockMove(models.Model):
res['origin'] = ','.join(productions.mapped('name'))
res['retrospect_ref'] = production.product_id.name
return res
-
- subcontract_workorder_id = fields.Many2one('mrp.workorder', '外协工单组件', check_company=True, index='btree_not_null')
+
+ subcontract_workorder_id = fields.Many2one('mrp.workorder', '外协工单组件', check_company=True,
+ index='btree_not_null')
class ReStockQuant(models.Model):
diff --git a/sf_manufacturing/views/model_type_view.xml b/sf_manufacturing/views/model_type_view.xml
index 0f8b3085..f4c1f994 100644
--- a/sf_manufacturing/views/model_type_view.xml
+++ b/sf_manufacturing/views/model_type_view.xml
@@ -3,7 +3,7 @@
#------------------模型类型------------------
-
+
search.sf.model.type
sf.model.type
@@ -14,7 +14,7 @@
-
+
tree.sf.model.type
sf.model.type
@@ -24,7 +24,7 @@
-
+
form.sf.model.type
sf.model.type
@@ -37,7 +37,7 @@
-
+
@@ -48,7 +48,7 @@
-
+
@@ -59,7 +59,7 @@
-
+
@@ -70,7 +70,7 @@
-
+
@@ -81,7 +81,7 @@
-
+
模型类型
ir.actions.act_window
sf.model.type
@@ -96,11 +96,11 @@
\ No newline at end of file
diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml
index 043990ef..d08ff81f 100644
--- a/sf_manufacturing/views/mrp_production_addional_change.xml
+++ b/sf_manufacturing/views/mrp_production_addional_change.xml
@@ -442,7 +442,7 @@
diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml
index 3828f00e..1a2682be 100644
--- a/sf_manufacturing/views/mrp_workorder_view.xml
+++ b/sf_manufacturing/views/mrp_workorder_view.xml
@@ -55,7 +55,7 @@
{'invisible': ['|', '|', '|','|','|', ('production_state','in', ('draft',
'done',
- 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')),
+ 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done','rework', 'cancel')),
('is_user_working', '!=', False),("user_permissions","=",False),("name","in",("CNC加工","解除装夹"))]}
@@ -174,9 +174,9 @@
+ attrs="{'invisible': ['|', '|', '|', '|', '|', ('routing_type', '=', '装夹预调'), ('routing_type', '=', '解除装夹'), ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done','rework', 'cancel','to be detected')), ('is_user_working', '!=', False)]}"/>
+ attrs="{'invisible': ['|', '|', '|', '|', ('routing_type', '!=', '装夹预调'), ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done','rework', 'cancel','to be detected')), ('is_user_working', '!=', False)]}"/>