From 7227e1e59cf22e4bbeb14037f02fdd23457d7d25 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 25 Oct 2024 14:58:29 +0800 Subject: [PATCH 001/201] =?UTF-8?q?=E6=B3=A8=E9=87=8Aocc=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 4 ++-- sf_sale/models/quick_easy_order.py | 4 ++-- sf_sale/models/quick_easy_order_old.py | 4 ++-- sf_sale/views/quick_easy_order_view.xml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 0b512c36..e61f9b32 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError from odoo.modules import get_resource_path -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index 081807a4..cb1886a1 100644 --- a/sf_sale/models/quick_easy_order.py +++ b/sf_sale/models/quick_easy_order.py @@ -8,8 +8,8 @@ from datetime import datetime import requests from odoo import http from odoo.http import request -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file from odoo import models, fields, api from odoo.modules import get_resource_path from odoo.exceptions import ValidationError, UserError diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index 5207ec15..46724fc6 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -6,8 +6,8 @@ import os from datetime import datetime from stl import mesh # from OCC.Core.GProp import GProp_GProps -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file from odoo.addons.sf_base.commons.common import Common from odoo import models, fields, api from odoo.modules import get_resource_path diff --git a/sf_sale/views/quick_easy_order_view.xml b/sf_sale/views/quick_easy_order_view.xml index 9111403d..22c342f2 100644 --- a/sf_sale/views/quick_easy_order_view.xml +++ b/sf_sale/views/quick_easy_order_view.xml @@ -74,7 +74,7 @@ - + From 537fbf7e14b50389ce882bb126ca090cf5e8f777 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 25 Oct 2024 17:19:10 +0800 Subject: [PATCH 002/201] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 573bb73f..1b9ddf39 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -836,6 +836,7 @@ class MrpProduction(models.Model): backorders = backorders - productions_to_backorder productions_not_to_backorder._post_inventory(cancel_backorder=True) + #查出最后一张工单完成入库操作 # if self.workorder_ids.filtered(lambda w: w.routing_type in ['表面工艺']): # move_finish = self.env['stock.move'].search([('created_production_id', '=', self.id)]) # if move_finish: From 1d14ab27af01b55adcae0eaabac3d173de5be114 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 5 Nov 2024 09:50:24 +0800 Subject: [PATCH 003/201] =?UTF-8?q?=E8=AD=A6=E5=91=8A=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_maintenance/models/sf_maintenance_oee.py | 42 ++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/sf_maintenance/models/sf_maintenance_oee.py b/sf_maintenance/models/sf_maintenance_oee.py index 0889fdb5..eef42a60 100644 --- a/sf_maintenance/models/sf_maintenance_oee.py +++ b/sf_maintenance/models/sf_maintenance_oee.py @@ -62,22 +62,22 @@ class SfMaintenanceEquipmentOEE(models.Model): ("封存(报废)", "封存(报废)")], default='正常', string="机床状态", related='equipment_id.state') - online_time = fields.Char('开机时长(小时)', reaonly='True') + online_time = fields.Char('开机时长(小时)', readonly='True') - offline_time = fields.Char('关机时长(小时)', reaonly='True') - idle_nums = fields.Integer('待机次数', reaonly='True') + offline_time = fields.Char('关机时长(小时)', readonly='True') + idle_nums = fields.Integer('待机次数', readonly='True') # 待机时长 - idle_time = fields.Char('待机时长(小时)', reaonly='True') + idle_time = fields.Char('待机时长(小时)', readonly='True') # 待机率 - idle_rate = fields.Char('待机率(%)', reaonly='True') + idle_rate = fields.Char('待机率(%)', readonly='True') - work_time = fields.Char('加工时长(小时)', reaonly='True') - work_rate = fields.Char('可用率(%)', reaonly='True') - fault_time = fields.Char('故障时长(小时)', reaonly='True') - fault_rate = fields.Char('故障率(%)', reaonly='True') - fault_nums = fields.Integer('故障次数', reaonly='True') + work_time = fields.Char('加工时长(小时)', readonly='True') + work_rate = fields.Char('可用率(%)', readonly='True') + fault_time = fields.Char('故障时长(小时)', readonly='True') + fault_rate = fields.Char('故障率(%)', readonly='True') + fault_nums = fields.Integer('故障次数', readonly='True') # 设备故障日志 sf_maintenance_logs_ids = fields.One2many('sf.maintenance.logs', 'maintenance_equipment_oee_id', '设备故障日志', @@ -367,25 +367,25 @@ class SfMaintenanceEquipmentOEELog(models.Model): [("ZXJGZX", "钻铣加工中心"), ("CXJGZX", "车削加工中心"), ("FHJGZX", "复合加工中心")], default="", string="功能类型") machine_tool_picture = fields.Binary('设备图片') - type_id = fields.Many2one('sf.machine_tool.type', '品牌型号', reaonly='True') + type_id = fields.Many2one('sf.machine_tool.type', '品牌型号', readonly='True') state = fields.Selection([("加工", "加工"), ("关机", "关机"), ("待机", "待机"), ("故障", "故障"), ("检修", "检修"), ("保养", "保养")], default="", string="实时状态") - online_time = fields.Char('开机时长', reaonly='True') + online_time = fields.Char('开机时长', readonly='True') - offline_time = fields.Char('关机时长', reaonly='True') - offline_nums = fields.Integer('关机次数', reaonly='True') + offline_time = fields.Char('关机时长', readonly='True') + offline_nums = fields.Integer('关机次数', readonly='True') # 待机时长 - idle_time = fields.Char('待机时长', reaonly='True') + idle_time = fields.Char('待机时长', readonly='True') # 待机率 - idle_rate = fields.Char('待机率', reaonly='True') + idle_rate = fields.Char('待机率', readonly='True') - work_time = fields.Char('加工时长', reaonly='True') - work_rate = fields.Char('可用率', reaonly='True') - fault_time = fields.Char('故障时长', reaonly='True') - fault_rate = fields.Char('故障率', reaonly='True') - fault_nums = fields.Integer('故障次数', reaonly='True') + work_time = fields.Char('加工时长', readonly='True') + work_rate = fields.Char('可用率', readonly='True') + fault_time = fields.Char('故障时长', readonly='True') + fault_rate = fields.Char('故障率', readonly='True') + fault_nums = fields.Integer('故障次数', readonly='True') detail_ids = fields.One2many('maintenance.equipment.oee.log.detail', 'log_id', string='日志详情') From 8ea72198eaa751bfb9a9d67bc519731bd43b892b Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 5 Nov 2024 17:52:18 +0800 Subject: [PATCH 004/201] =?UTF-8?q?1=E3=80=81=E5=AE=8C=E6=88=90=E6=8A=A5?= =?UTF-8?q?=E4=BB=B7=E5=8D=95=E4=BC=98=E5=8C=96=E9=9C=80=E6=B1=82=EF=BC=9B?= =?UTF-8?q?2=E3=80=81=E4=BF=AE=E6=94=B9=E5=88=B6=E9=80=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=86=85=E8=A3=85=E5=A4=B9=E5=B7=A5=E5=8D=95=E7=9A=84?= =?UTF-8?q?=E2=80=98=E8=BF=94=E5=B7=A5=E2=80=99=E6=8C=89=E9=92=AE=E4=B8=BA?= =?UTF-8?q?=E2=80=99=E5=BC=82=E5=B8=B8=E5=8F=8D=E9=A6=88=E2=80=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/views/mrp_workorder_view.xml | 2 +- sf_sale/views/sale_order_view.xml | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 8d3c6c4f..bb06fa04 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -197,7 +197,7 @@ - + + + diff --git a/sf_manufacturing/views/mrp_routing_workcenter_view.xml b/sf_manufacturing/views/mrp_routing_workcenter_view.xml index eada92d9..ddb9558c 100644 --- a/sf_manufacturing/views/mrp_routing_workcenter_view.xml +++ b/sf_manufacturing/views/mrp_routing_workcenter_view.xml @@ -16,6 +16,7 @@ + From 1f11d188c115857a7af6e5a82956eeac8b642b5c Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 6 Nov 2024 17:46:14 +0800 Subject: [PATCH 010/201] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=A5=E8=89=BA?= =?UTF-8?q?=E5=B7=A5=E7=A8=8B=E5=B8=88=E6=9D=83=E9=99=90=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/security/group_security.xml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sf_base/security/group_security.xml b/sf_base/security/group_security.xml index b45a2dbd..5224519f 100644 --- a/sf_base/security/group_security.xml +++ b/sf_base/security/group_security.xml @@ -1,6 +1,6 @@ - + 质检岗 @@ -46,6 +46,11 @@ + + 工艺工程师 + + + 计划 @@ -65,7 +70,7 @@ 计划调度岗 - + From 23db164452479a38c20cdb47eae7ef514ef52ab0 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 6 Nov 2024 17:48:27 +0800 Subject: [PATCH 011/201] =?UTF-8?q?=E5=88=B6=E9=80=A0=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=A5=E8=89=BA=E5=B7=A5=E7=A8=8B=E5=B8=88?= =?UTF-8?q?=E6=9D=83=E9=99=90=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/security/ir.model.access.csv | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv index be71cb0d..7c0d377e 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -165,6 +165,10 @@ access_sf_agv_scheduling_group_sf_order_user,sf_agv_scheduling_group_sf_order_us access_sf_agv_scheduling_group_sf_mrp_manager,sf_agv_scheduling_group_sf_mrp_manager,model_sf_agv_scheduling,sf_base.group_sf_mrp_manager,1,1,1,0 access_sf_agv_scheduling_group_sf_equipment_user,sf_agv_scheduling_group_sf_equipment_user,model_sf_agv_scheduling,sf_base.group_sf_equipment_user,1,1,1,0 +access_sf_technology_design_group_plan_dispatch,sf_technology_design_group_plan_dispatch,model_sf_technology_design,sf_base.group_plan_dispatch,1,1,1,0 +access_sf_technology_design_group_sf_mrp_manager,sf_technology_design_group_sf_mrp_manager,model_sf_technology_design,sf_base.group_sf_mrp_manager,1,1,1,0 +access_sf_technology_design_group_production_engineer,sf_technology_design_group_production_engineer,model_sf_technology_design,sf_base.group_production_engineer,1,1,1,0 + From 111c0f6dae80c8cd7ff491011d1207ab2dacd57c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Wed, 6 Nov 2024 17:53:33 +0800 Subject: [PATCH 012/201] =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jikimo_sale_route_picking/__init__.py | 4 + jikimo_sale_route_picking/__manifest__.py | 26 ++++++ .../controllers/__init__.py | 2 + jikimo_sale_route_picking/controllers/main.py | 46 ++++++++++ .../data/product_templates.xml | 85 +++++++++++++++++++ .../data/stock_routes.xml | 31 +++++++ jikimo_sale_route_picking/models/__init__.py | 3 + .../models/product_product.py | 7 ++ .../models/product_template.py | 10 +++ .../security/group_security.xml | 10 +++ .../security/ir.model.access.csv | 8 ++ .../views/product_product_views.xml | 15 ++++ .../views/sale_order_views.xml | 83 ++++++++++++++++++ .../product_template_management_view.xml | 10 +-- sf_plan_management/i18n/zh_CN.po | 2 +- sf_sale/models/sale_order.py | 10 +-- sf_sale/views/sale_order_view.xml | 8 +- 17 files changed, 342 insertions(+), 18 deletions(-) create mode 100644 jikimo_sale_route_picking/__init__.py create mode 100644 jikimo_sale_route_picking/__manifest__.py create mode 100644 jikimo_sale_route_picking/controllers/__init__.py create mode 100644 jikimo_sale_route_picking/controllers/main.py create mode 100644 jikimo_sale_route_picking/data/product_templates.xml create mode 100644 jikimo_sale_route_picking/data/stock_routes.xml create mode 100644 jikimo_sale_route_picking/models/__init__.py create mode 100644 jikimo_sale_route_picking/models/product_product.py create mode 100644 jikimo_sale_route_picking/models/product_template.py create mode 100644 jikimo_sale_route_picking/security/group_security.xml create mode 100644 jikimo_sale_route_picking/security/ir.model.access.csv create mode 100644 jikimo_sale_route_picking/views/product_product_views.xml create mode 100644 jikimo_sale_route_picking/views/sale_order_views.xml diff --git a/jikimo_sale_route_picking/__init__.py b/jikimo_sale_route_picking/__init__.py new file mode 100644 index 00000000..7909ef3a --- /dev/null +++ b/jikimo_sale_route_picking/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +from . import models + +from . import controllers diff --git a/jikimo_sale_route_picking/__manifest__.py b/jikimo_sale_route_picking/__manifest__.py new file mode 100644 index 00000000..b72e9a37 --- /dev/null +++ b/jikimo_sale_route_picking/__manifest__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +{ + 'name': '机企猫 供货路线选择', + 'version': '16.0.1.0.0', + 'summary': """ 报价单提供(自动化产线加工/人工线下加工/外购/委外加工)多种供货路线选择 """, + 'author': 'fox', + 'website': '', + 'category': '', + 'depends': ['product', 'sf_dlm_management', 'sale_stock'], + "data": [ + 'security/group_security.xml', + 'security/ir.model.access.csv', + 'data/stock_routes.xml', + 'data/product_templates.xml', + 'views/sale_order_views.xml', + 'views/product_product_views.xml', + ],'assets': { + # 'web.assets_backend': [ + # 'jikimo_sale_route_picking/static/src/**/*' + # ], + }, + 'application': True, + 'installable': True, + 'auto_install': False, + 'license': 'LGPL-3', +} diff --git a/jikimo_sale_route_picking/controllers/__init__.py b/jikimo_sale_route_picking/controllers/__init__.py new file mode 100644 index 00000000..cd4d6a8b --- /dev/null +++ b/jikimo_sale_route_picking/controllers/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import main \ No newline at end of file diff --git a/jikimo_sale_route_picking/controllers/main.py b/jikimo_sale_route_picking/controllers/main.py new file mode 100644 index 00000000..0c0390e7 --- /dev/null +++ b/jikimo_sale_route_picking/controllers/main.py @@ -0,0 +1,46 @@ +import logging +import json +from odoo import http +from odoo.http import request +from odoo.addons.sf_bf_connect.controllers.controllers import Sf_Bf_Connect + +_logger = logging.getLogger(__name__) + +class JikimoSaleRoutePicking(Sf_Bf_Connect): + + @http.route('/api/bfm_process_order/list', type='http', auth='sf_token', methods=['GET', 'POST'], csrf=False, + cors="*") + def get_bfm_process_order_list(self, **kw): + """ + 接收业务平台加工订单分配工厂时传送来的订单数据并生成销售订单和产品及坯料 + :param kw: + :return: + """ + res = {'status': 1, 'factory_order_no': ''} + _logger.info('get_bfm_process_order_list:%s' % kw['order_number']) + try: + product_id = request.env.ref('jikimo_sale_route_picking.product_template_default').sudo() + company_id = request.env.ref('base.main_company').sudo() + bfm_process_order_list = json.loads(kw['bfm_process_order_list']) + order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create( + company_id, kw['delivery_name'], kw['delivery_telephone'], kw['delivery_address'], + kw['delivery_end_date'], kw['payments_way'], kw['pay_way'], state='draft') + i = 1 + # 给sale_order的default_code字段赋值 + aa = request.env['sale.order'].sudo().search([('name', '=', order_id.name)]) + _logger.info('get_bfm_process_or===================================:%s' % order_id.name) + aa.default_code = kw['order_number'] + if kw.get('logistics_way'): + aa.logistics_way = kw['logistics_way'] + _logger.info('get_bfm_process_order_listaaaaaaaaaaaaaaaaaaaaaaaaaaaa================:%s' % aa.default_code) + for item in bfm_process_order_list: + product = request.env['product.template'].sudo().product_create(product_id, item, order_id, + kw['order_number'], i) + order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item) + i += 1 + res['factory_order_no'] = order_id.name + except Exception as e: + _logger.info('get_bfm_process_order_list error:%s' % e) + res['status'] = -1 + res['message'] = '工厂创建销售订单和产品失败,请联系管理员' + return json.JSONEncoder().encode(res) diff --git a/jikimo_sale_route_picking/data/product_templates.xml b/jikimo_sale_route_picking/data/product_templates.xml new file mode 100644 index 00000000..df965fd0 --- /dev/null +++ b/jikimo_sale_route_picking/data/product_templates.xml @@ -0,0 +1,85 @@ + + + + + 人工线下加工模板 + + + + delivery + product + false + + + + true + serial + true + true + + + + 成品外购模板 + + + + serial + product + + + + true + + + + 成品委外加工模板 + + + + serial + product + + + + true + + + + 成品初始化模板 + + + + serial + product + + + + true + + + + + + + + + 坯料客供料模板 + + + + false + serial + product + + + + + + + \ No newline at end of file diff --git a/jikimo_sale_route_picking/data/stock_routes.xml b/jikimo_sale_route_picking/data/stock_routes.xml new file mode 100644 index 00000000..eb6a340c --- /dev/null +++ b/jikimo_sale_route_picking/data/stock_routes.xml @@ -0,0 +1,31 @@ + + + + + 带料加工 + true + true + + 16 + + + + 客供料入库 + incoming + true + + DL + + + + + + 带料收货 + + + + + pull + + + \ No newline at end of file diff --git a/jikimo_sale_route_picking/models/__init__.py b/jikimo_sale_route_picking/models/__init__.py new file mode 100644 index 00000000..f59a4700 --- /dev/null +++ b/jikimo_sale_route_picking/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +from . import product_template +from . import product_product diff --git a/jikimo_sale_route_picking/models/product_product.py b/jikimo_sale_route_picking/models/product_product.py new file mode 100644 index 00000000..996a9d5c --- /dev/null +++ b/jikimo_sale_route_picking/models/product_product.py @@ -0,0 +1,7 @@ +from odoo import models, fields + +class ProductProduct(models.Model): + _inherit = 'product.product' + + # 是否客供料 + is_customer_provided = fields.Boolean(string='是否客供料', related='product_tmpl_id.is_customer_provided') diff --git a/jikimo_sale_route_picking/models/product_template.py b/jikimo_sale_route_picking/models/product_template.py new file mode 100644 index 00000000..6b2bc29d --- /dev/null +++ b/jikimo_sale_route_picking/models/product_template.py @@ -0,0 +1,10 @@ +from odoo import models, fields + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + is_manual_processing = fields.Boolean(string='人工线下加工') + is_customer_provided = fields.Boolean(string='客供料') + + def product_create(self, product_id, item, order_id, order_number, i): + product_id = super(ProductTemplate, self).product_create(product_id, item, order_id, order_number, i) diff --git a/jikimo_sale_route_picking/security/group_security.xml b/jikimo_sale_route_picking/security/group_security.xml new file mode 100644 index 00000000..84bf5b89 --- /dev/null +++ b/jikimo_sale_route_picking/security/group_security.xml @@ -0,0 +1,10 @@ + + + + + + 工艺工程师 + + + + \ No newline at end of file diff --git a/jikimo_sale_route_picking/security/ir.model.access.csv b/jikimo_sale_route_picking/security/ir.model.access.csv new file mode 100644 index 00000000..aac13f29 --- /dev/null +++ b/jikimo_sale_route_picking/security/ir.model.access.csv @@ -0,0 +1,8 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_sale_order_group_production_engineer,sale.order_group_production_engineer,sale.model_sale_order,jikimo_sale_route_picking.group_production_engineer,1,1,0,0 +access_sale_order_line_group_production_engineer,sale_order_line_group_production_engineer,sale.model_sale_order_line,jikimo_sale_route_picking.group_production_engineer,1,1,0,0 +access_product_product_group_production_engineer,product_product_group_production_engineer,product.model_product_product,jikimo_sale_route_picking.group_production_engineer,1,0,0,0 +access_product_template_group_production_engineer,product_template_group_production_engineer,product.model_product_template,jikimo_sale_route_picking.group_production_engineer,1,0,0,0 +access_stock_picking_group_production_engineer,stock_picking_group_production_engineer,stock.model_stock_picking,jikimo_sale_route_picking.group_production_engineer,1,0,0,0 +access_stock_move_group_production_engineer,stock_move_group_production_engineer,stock.model_stock_move,jikimo_sale_route_picking.group_production_engineer,1,0,0,0 +access_mrp_bom_group_production_engineer,mrp_bom_group_production_engineer,mrp.model_mrp_bom,jikimo_sale_route_picking.group_production_engineer,1,0,0,0 \ No newline at end of file diff --git a/jikimo_sale_route_picking/views/product_product_views.xml b/jikimo_sale_route_picking/views/product_product_views.xml new file mode 100644 index 00000000..e3f896b5 --- /dev/null +++ b/jikimo_sale_route_picking/views/product_product_views.xml @@ -0,0 +1,15 @@ + + + + view.product.template.form.inherit.sf + product.template + + + + + + + + + + \ No newline at end of file diff --git a/jikimo_sale_route_picking/views/sale_order_views.xml b/jikimo_sale_route_picking/views/sale_order_views.xml new file mode 100644 index 00000000..027a3054 --- /dev/null +++ b/jikimo_sale_route_picking/views/sale_order_views.xml @@ -0,0 +1,83 @@ + + + + view.sale.order.form.inherit.sf + + sale.order + + + + + + + + + + jikimo.sale.order.search.inherit.quotation + sale.order + primary + + + + + + + + + + jikimo.sale.order.search.inherit.quotation + sale.order + primary + + + + + + + + + + + + + + + + + 报价单 + ir.actions.act_window + sale.order + tree,kanban,form,calendar,pivot,graph,activity + + {'search_default_route': 1} + +

+ Create a new quotation, the first step of a new sale! +

+ Once the quotation is confirmed by the customer, it becomes a sales order.
You will be able to create an invoice and collect the payment. +

+
+
+ + + + + + + +
diff --git a/sf_dlm_management/views/product_template_management_view.xml b/sf_dlm_management/views/product_template_management_view.xml index 1862e33c..0fe6413b 100644 --- a/sf_dlm_management/views/product_template_management_view.xml +++ b/sf_dlm_management/views/product_template_management_view.xml @@ -110,15 +110,13 @@ - - + + - - + + diff --git a/sf_plan_management/i18n/zh_CN.po b/sf_plan_management/i18n/zh_CN.po index 0b957921..d9511db1 100644 --- a/sf_plan_management/i18n/zh_CN.po +++ b/sf_plan_management/i18n/zh_CN.po @@ -7059,7 +7059,7 @@ msgstr "" #. module: sf_dlm #: model:product.template,name:sf_dlm.product_template_sf_product_template msgid "CNC加工产品模板" -msgstr "冲压模具滑块" +msgstr "自动化产线加工模板" #. module: sf_tool_management #: model:ir.model,name:sf_tool_management.model_sf_cnc_processing diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index 53f73aef..251554b5 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -60,7 +60,7 @@ class ReSaleOrder(models.Model): # 业务平台分配工厂后在智能工厂先创建销售订单 def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address, - deadline_of_delivery, payments_way, pay_way): + deadline_of_delivery, payments_way, pay_way, state='sale'): now_time = datetime.datetime.now() partner = self.get_customer() data = { @@ -69,7 +69,7 @@ class ReSaleOrder(models.Model): 'name': self.env['ir.sequence'].next_by_code('sale.order', sequence_date=now_time), 'partner_id': partner.id, 'check_status': 'approved', - 'state': 'sale', + 'state': state, 'user_id': partner.user_id.id, 'person_of_delivery': delivery_name, 'telephone_of_delivery': delivery_telephone, @@ -133,8 +133,7 @@ class ReSaleOrder(models.Model): 'product_uom_qty': item['number'], 'model_glb_file': base64.b64decode(item['model_file']), 'remark': item.get('remark'), - 'is_incoming_material': item.get('is_incoming_material'), - 'incoming_size': item.get('incoming_size'), + 'is_incoming_material': item.get('is_incoming_material') } return self.env['sale.order.line'].with_context(skip_procurement=True).create(vals) @@ -175,8 +174,7 @@ class ResaleOrderLine(models.Model): check_status = fields.Selection(related='order_id.check_status') remark = fields.Char('备注') - is_incoming_material = fields.Boolean('是否带料', default=False) - incoming_size = fields.Char('带料尺寸') + is_incoming_material = fields.Boolean('客供料', default=False) @api.depends('product_template_id') def _compute_model_glb_file(self): diff --git a/sf_sale/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml index a84a2b44..f5dba649 100644 --- a/sf_sale/views/sale_order_view.xml +++ b/sf_sale/views/sale_order_view.xml @@ -118,8 +118,7 @@ - - + {'readonly': [('state', 'in', ['cancel','sale'])]} @@ -167,7 +166,6 @@ -
@@ -207,12 +205,12 @@ 下单时间 - +
From 6679c200e1e936ae9de812cf72566a90587108ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Thu, 7 Nov 2024 08:41:25 +0800 Subject: [PATCH 013/201] =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jikimo_sale_route_picking/__manifest__.py | 1 - .../security/group_security.xml | 10 ---------- .../security/ir.model.access.csv | 14 +++++++------- .../views/sale_order_views.xml | 6 +++--- 4 files changed, 10 insertions(+), 21 deletions(-) delete mode 100644 jikimo_sale_route_picking/security/group_security.xml diff --git a/jikimo_sale_route_picking/__manifest__.py b/jikimo_sale_route_picking/__manifest__.py index b72e9a37..e3da3a60 100644 --- a/jikimo_sale_route_picking/__manifest__.py +++ b/jikimo_sale_route_picking/__manifest__.py @@ -8,7 +8,6 @@ 'category': '', 'depends': ['product', 'sf_dlm_management', 'sale_stock'], "data": [ - 'security/group_security.xml', 'security/ir.model.access.csv', 'data/stock_routes.xml', 'data/product_templates.xml', diff --git a/jikimo_sale_route_picking/security/group_security.xml b/jikimo_sale_route_picking/security/group_security.xml deleted file mode 100644 index 84bf5b89..00000000 --- a/jikimo_sale_route_picking/security/group_security.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - 工艺工程师 - - - - \ No newline at end of file diff --git a/jikimo_sale_route_picking/security/ir.model.access.csv b/jikimo_sale_route_picking/security/ir.model.access.csv index aac13f29..3b276af9 100644 --- a/jikimo_sale_route_picking/security/ir.model.access.csv +++ b/jikimo_sale_route_picking/security/ir.model.access.csv @@ -1,8 +1,8 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_sale_order_group_production_engineer,sale.order_group_production_engineer,sale.model_sale_order,jikimo_sale_route_picking.group_production_engineer,1,1,0,0 -access_sale_order_line_group_production_engineer,sale_order_line_group_production_engineer,sale.model_sale_order_line,jikimo_sale_route_picking.group_production_engineer,1,1,0,0 -access_product_product_group_production_engineer,product_product_group_production_engineer,product.model_product_product,jikimo_sale_route_picking.group_production_engineer,1,0,0,0 -access_product_template_group_production_engineer,product_template_group_production_engineer,product.model_product_template,jikimo_sale_route_picking.group_production_engineer,1,0,0,0 -access_stock_picking_group_production_engineer,stock_picking_group_production_engineer,stock.model_stock_picking,jikimo_sale_route_picking.group_production_engineer,1,0,0,0 -access_stock_move_group_production_engineer,stock_move_group_production_engineer,stock.model_stock_move,jikimo_sale_route_picking.group_production_engineer,1,0,0,0 -access_mrp_bom_group_production_engineer,mrp_bom_group_production_engineer,mrp.model_mrp_bom,jikimo_sale_route_picking.group_production_engineer,1,0,0,0 \ No newline at end of file +access_sale_order_group_production_engineer,sale.order_group_production_engineer,sale.model_sale_order,sf_base.group_production_engineer,1,1,0,0 +access_sale_order_line_group_production_engineer,sale_order_line_group_production_engineer,sale.model_sale_order_line,sf_base.group_production_engineer,1,1,0,0 +access_product_product_group_production_engineer,product_product_group_production_engineer,product.model_product_product,sf_base.group_production_engineer,1,0,0,0 +access_product_template_group_production_engineer,product_template_group_production_engineer,product.model_product_template,sf_base.group_production_engineer,1,0,0,0 +access_stock_picking_group_production_engineer,stock_picking_group_production_engineer,stock.model_stock_picking,sf_base.group_production_engineer,1,0,0,0 +access_stock_move_group_production_engineer,stock_move_group_production_engineer,stock.model_stock_move,sf_base.group_production_engineer,1,0,0,0 +access_mrp_bom_group_production_engineer,mrp_bom_group_production_engineer,mrp.model_mrp_bom,sf_base.group_production_engineer,1,0,0,0 \ No newline at end of file diff --git a/jikimo_sale_route_picking/views/sale_order_views.xml b/jikimo_sale_route_picking/views/sale_order_views.xml index 027a3054..a178df0a 100644 --- a/jikimo_sale_route_picking/views/sale_order_views.xml +++ b/jikimo_sale_route_picking/views/sale_order_views.xml @@ -60,14 +60,14 @@ From 9a4d7e87ec5af7d53ef2ee1576c53e9ca5056cc9 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 7 Nov 2024 10:43:08 +0800 Subject: [PATCH 014/201] =?UTF-8?q?1=E3=80=81=E5=A4=84=E7=90=86=E9=94=80?= =?UTF-8?q?=E5=94=AE=E5=8D=95=E7=9A=84=E4=BE=9D=E8=B5=96=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E6=9B=B4=E6=96=B0=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9B2=E3=80=81=E4=BC=98=E5=8C=96=E5=AE=A2=E4=BE=9B?= =?UTF-8?q?=E6=96=99=E5=8D=95=E6=8D=AE=E8=8E=B7=E5=8F=96=E9=94=80=E5=94=AE?= =?UTF-8?q?=E5=8D=95=E5=AD=97=E6=AE=B5=E4=BF=A1=E6=81=AF=E5=92=8C=E6=88=90?= =?UTF-8?q?=E5=93=81=E4=BF=A1=E6=81=AF=E6=96=B9=E6=B3=95=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/base.py | 8 +++ .../views/maintenance_request_views.xml | 2 +- sf_manufacturing/models/stock.py | 55 +++++++++++-------- sf_sale/models/sale_order.py | 6 +- sf_tool_management/views/tool_base_views.xml | 2 +- 5 files changed, 44 insertions(+), 29 deletions(-) diff --git a/sf_base/models/base.py b/sf_base/models/base.py index 3d83cc96..2c4bf22a 100644 --- a/sf_base/models/base.py +++ b/sf_base/models/base.py @@ -402,3 +402,11 @@ class MachiningAccuracy(models.Model): name = fields.Char('一般公差', index=True) standard_tolerance = fields.Char(string="标准公差") sync_id = fields.Char('同步ID') + + +class ReSaleOrder(models.Model): + _inherit = 'sale.order' + + person_of_delivery = fields.Char('收货人') + telephone_of_delivery = fields.Char('电话号码') + address_of_delivery = fields.Char('联系地址') diff --git a/sf_maintenance/views/maintenance_request_views.xml b/sf_maintenance/views/maintenance_request_views.xml index 9353e80e..b76326b8 100644 --- a/sf_maintenance/views/maintenance_request_views.xml +++ b/sf_maintenance/views/maintenance_request_views.xml @@ -139,7 +139,7 @@ 维保计划 maintenance.request tree,kanban,form,pivot,graph,calendar - + {'default_user_id': uid}

diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index fb678fd3..55667d41 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -548,35 +548,42 @@ class StockPicking(models.Model): _inherit = 'stock.picking' surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数") - person_of_delivery = fields.Char('收货人', compute='_compute_origin', store=True) - telephone_of_delivery = fields.Char('电话号码', compute='_compute_origin', store=True) - address_of_delivery = fields.Char('联系地址', compute='_compute_origin') + person_of_delivery = fields.Char('收货人', compute='_compute_move_ids', store=True) + telephone_of_delivery = fields.Char('电话号码', compute='_compute_move_ids', store=True) + address_of_delivery = fields.Char('联系地址', compute='_compute_move_ids', store=True) - retrospect_ref = fields.Char('追溯参考', compute='_compute_origin', store=True) + retrospect_ref = fields.Char('追溯参考', compute='_compute_move_ids', store=True) - @api.depends('origin') - def _compute_origin(self): - """ - 计算带料入库单对应销售单 - """ + @api.depends('move_ids') + def _compute_move_ids(self): for item in self: - if item.picking_type_id.sequence_code == 'DL' and item.origin: - if 'WH/IN/' in item.origin: - picking_id = self.env['stock.picking'].search([('name', '=', item.origin)]) - if picking_id and picking_id.origin: - purchase_id = self.env['purchase.order'].sudo().search([('name', '=', picking_id.origin)]) - if purchase_id and purchase_id.origin: - sale_id = self.env['sale.order'].sudo().search([('name', '=', purchase_id.origin)]) - item.person_of_delivery = sale_id.person_of_delivery - item.telephone_of_delivery = sale_id.telephone_of_delivery - item.address_of_delivery = sale_id.address_of_delivery - - bom = self.env['mrp.bom'].sudo().search([('bom_line_ids.product_id', '=', self.move_ids.product_id.id)]) - if bom: + if item.move_ids: if item.picking_type_id.sequence_code == 'DL': - item.retrospect_ref = bom.product_tmpl_id.default_code + sale_name = item.move_ids[0].product_id.name.split('-')[1] + if 'S' in sale_name: + sale_id = self.env['sale.order'].sudo().search([('name', '=', sale_name)]) + item.person_of_delivery = sale_id.person_of_delivery + item.telephone_of_delivery = sale_id.telephone_of_delivery + item.address_of_delivery = sale_id.address_of_delivery + else: + raise ValidationError('坯料名称格式错误,正确格式为[R-S???-?]!!!') + move_ids = [] + for move_id in item.move_ids: + move_ids.append(move_id.product_id.id) + boms = self.env['mrp.bom'].sudo().search([('bom_line_ids.product_id', 'in', move_ids)]) + default_codes = '' + if boms: + for bom in boms: + code = bom.product_tmpl_id.default_code.split('-')[-1] + default_code = bom.product_tmpl_id.default_code.split(f'-{code}')[0] + if default_code not in default_codes: + if default_codes == '': + default_codes = default_code + else: + default_codes = default_codes + ',' + default_code + item.retrospect_ref = default_codes elif item.picking_type_id.sequence_code in ['INT', 'PC']: - item.retrospect_ref = bom.product_tmpl_id.name + pass # 设置外协出入单的名称 def _get_name_Res(self, rescode): diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index bc34c134..01d5953b 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -32,9 +32,9 @@ class ReSaleOrder(models.Model): tracking=3, default='draft') deadline_of_delivery = fields.Date('订单交期', tracking=True) - person_of_delivery = fields.Char('收货人') - telephone_of_delivery = fields.Char('电话号码') - address_of_delivery = fields.Char('联系地址') + # person_of_delivery = fields.Char('收货人') + # telephone_of_delivery = fields.Char('电话号码') + # address_of_delivery = fields.Char('联系地址') payments_way = fields.Selection([('现结', '现结'), ('月结', '月结')], '结算方式', default='现结', tracking=True) pay_way = fields.Selection([('转账', '转账'), ('微信', '微信'), ('支付宝', '支付宝')], '支付方式') check_status = fields.Selection([('pending', '待审核'), ('approved', '已审核'), ('fail', '不通过')], '审核状态') diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index a83faa6a..092e0113 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -450,7 +450,7 @@ - + Date: Thu, 7 Nov 2024 11:22:31 +0800 Subject: [PATCH 015/201] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/security/ir.model.access.csv | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv index 7c0d377e..a8511245 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -165,11 +165,6 @@ access_sf_agv_scheduling_group_sf_order_user,sf_agv_scheduling_group_sf_order_us access_sf_agv_scheduling_group_sf_mrp_manager,sf_agv_scheduling_group_sf_mrp_manager,model_sf_agv_scheduling,sf_base.group_sf_mrp_manager,1,1,1,0 access_sf_agv_scheduling_group_sf_equipment_user,sf_agv_scheduling_group_sf_equipment_user,model_sf_agv_scheduling,sf_base.group_sf_equipment_user,1,1,1,0 -access_sf_technology_design_group_plan_dispatch,sf_technology_design_group_plan_dispatch,model_sf_technology_design,sf_base.group_plan_dispatch,1,1,1,0 -access_sf_technology_design_group_sf_mrp_manager,sf_technology_design_group_sf_mrp_manager,model_sf_technology_design,sf_base.group_sf_mrp_manager,1,1,1,0 -access_sf_technology_design_group_production_engineer,sf_technology_design_group_production_engineer,model_sf_technology_design,sf_base.group_production_engineer,1,1,1,0 - - From 4d7b1f557b936ea2b242d8ff1eda4490acc868b8 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Thu, 7 Nov 2024 14:26:33 +0800 Subject: [PATCH 016/201] =?UTF-8?q?=E8=AF=A2=E4=BB=B7=E5=8D=95=E5=8C=BA?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_dlm/models/__init__.py | 2 ++ sf_dlm/models/stock_rule_inherit.py | 35 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 sf_dlm/models/stock_rule_inherit.py diff --git a/sf_dlm/models/__init__.py b/sf_dlm/models/__init__.py index 6619bd58..f5b994b6 100644 --- a/sf_dlm/models/__init__.py +++ b/sf_dlm/models/__init__.py @@ -1 +1,3 @@ from . import product_supplierinfo +from . import stock_rule_inherit + diff --git a/sf_dlm/models/stock_rule_inherit.py b/sf_dlm/models/stock_rule_inherit.py new file mode 100644 index 00000000..d20fcd58 --- /dev/null +++ b/sf_dlm/models/stock_rule_inherit.py @@ -0,0 +1,35 @@ +from odoo import models, fields, api, _ + + +class StockRuleInherit(models.Model): + _inherit = 'stock.rule' + + @api.model + def _run_buy(self, procurements): + # 首先调用父类的 _run_buy 方法,以保留原有逻辑 + super(StockRuleInherit, self)._run_buy(procurements) + + # 然后在这里添加自定义的逻辑 + for procurement, rule in procurements: + product = procurement.product_id + # 获取主 BOM + bom = self.env['mrp.bom'].search([('product_tmpl_id', '=', product.product_tmpl_id.id)], limit=1) + + if bom: + # 遍历 BOM 中的组件(即坯料等) + for line in bom.bom_line_ids: + raw_material = line.product_id + # 检查路线 + for route in raw_material.route_ids: + # print('route.name:', route.name) + if route.name == '按订单补给外包商': # 或者用 route.id 检查精确的路线 + print("按订单补给外包商============是") + # 使用 procurement.values['supplier'] 获取供应商 + supplier = procurement.values.get('supplier') + if supplier: + domain = rule._make_po_get_domain(procurement.company_id, procurement.values, + supplier.partner_id) + po = self.env['purchase.order'].sudo().search([dom for dom in domain], limit=1) + if po: + po.write({'purchase_type': 'consignment'}) + break From 330726007d54f7fb4cb632b8c0886fc3568696a5 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 7 Nov 2024 16:26:48 +0800 Subject: [PATCH 017/201] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E5=8F=AA?= =?UTF-8?q?=E6=9C=89=E5=AE=A2=E4=BE=9B=E6=96=99=E5=85=A5=E5=BA=93=E5=8D=95?= =?UTF-8?q?=E6=89=8D=E8=83=BD=E7=9C=8B=E8=A7=81=E6=94=B6=E8=B4=A7=E4=BA=BA?= =?UTF-8?q?/=E8=81=94=E7=B3=BB=E5=9C=B0=E5=9D=80/=E7=94=B5=E8=AF=9D?= =?UTF-8?q?=E5=8F=B7=E7=A0=81=E7=AD=89=E5=AD=97=E6=AE=B5;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_maintenance/models/sf_maintenance.py | 4 ++++ sf_manufacturing/models/stock.py | 19 +++++++++++-------- sf_manufacturing/views/stock_picking_view.xml | 11 +++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index 3d68bb9a..de6be8da 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -689,6 +689,8 @@ class SfMaintenanceEquipment(models.Model): if next_date < date_now: next_date = date_now else: + if not equipment.initial_action_date: + raise ValidationError('重置保养日期不能为空!!!') next_date = equipment.initial_action_date + timedelta(days=equipment.period) equipment.next_action_date = next_date else: @@ -735,6 +737,8 @@ class SfMaintenanceEquipment(models.Model): if next_date < date_now: next_date = date_now else: + if not equipment.initial_overhaul_date: + raise ValidationError('重置维修日期不能为空') next_date = equipment.initial_overhaul_date + timedelta(days=equipment.overhaul_period) equipment.overhaul_date = next_date else: diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 55667d41..2060ea48 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -554,7 +554,9 @@ class StockPicking(models.Model): retrospect_ref = fields.Char('追溯参考', compute='_compute_move_ids', store=True) - @api.depends('move_ids') + picking_type_sequence_code = fields.Char(related='picking_type_id.sequence_code') + + @api.depends('move_ids', 'move_ids.product_id') def _compute_move_ids(self): for item in self: if item.move_ids: @@ -574,13 +576,14 @@ class StockPicking(models.Model): default_codes = '' if boms: for bom in boms: - code = bom.product_tmpl_id.default_code.split('-')[-1] - default_code = bom.product_tmpl_id.default_code.split(f'-{code}')[0] - if default_code not in default_codes: - if default_codes == '': - default_codes = default_code - else: - default_codes = default_codes + ',' + default_code + if bom.product_tmpl_id.default_code: + code = bom.product_tmpl_id.default_code.split('-')[-1] + default_code = bom.product_tmpl_id.default_code.split(f'-{code}')[0] + if default_code not in default_codes: + if default_codes == '': + default_codes = default_code + else: + default_codes = default_codes + ',' + default_code item.retrospect_ref = default_codes elif item.picking_type_id.sequence_code in ['INT', 'PC']: pass diff --git a/sf_manufacturing/views/stock_picking_view.xml b/sf_manufacturing/views/stock_picking_view.xml index 356059c2..2fae1fac 100644 --- a/sf_manufacturing/views/stock_picking_view.xml +++ b/sf_manufacturing/views/stock_picking_view.xml @@ -18,10 +18,13 @@ - - - - + + + + + From d419efa3c327ab71ba702876afb0779ca0a26142 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 7 Nov 2024 17:59:28 +0800 Subject: [PATCH 018/201] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B7=A5=E8=89=BA?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 38 +++++++++++++++++++ .../models/mrp_routing_workcenter.py | 13 ++++++- .../models/sf_technology_design.py | 13 ++++--- sf_manufacturing/models/stock.py | 20 ++++------ .../views/mrp_production_addional_change.xml | 17 +++++++-- 5 files changed, 79 insertions(+), 22 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index ebe08942..54b1a61c 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -254,6 +254,44 @@ class MrpProduction(models.Model): if production.tool_state == '2': production.state = 'rework' + def technology_confirm(self): + # 判断同一个加工面的标准工序的顺序是否依次排序 + technology_design = self.technology_design_ids.sorted(key=lambda m: m.sequence) + current_design_index = None + for index, design in enumerate(technology_design.filtered(lambda a: a.routing_tag == 'standard')): + if design == current_design: + current_design_index = index + break # 找到了 current_design,跳出循环 + + # 现在我们有了 current_design 的索引,我们可以找到下一条设计 + if current_design_index is not None and current_design_index + 1 < len(technology_design): + next_design = technology_design[current_design_index + 1] + # 下一条设计是 next_design + else: + # 如果 current_design_index 为 None 或者没有下一条设计,则 next_design 为 None + next_design = None + for design in technology_design.filtered(lambda a: a.routing_tag == 'standard'): + routing_type = design.route_id.routing_type + if routing_type in ['装夹预调', 'CNC加工', '解除装夹']: + # standard_designs = [d for d in technology_design_ids if d.routing_tag == 'standard'] + # last_design = technology_design[technology_design.index(design) - 1] + next_design = technology_design[2] + for next_design in technology_design: + next_design_routing_type = next_design.route_id.routing_type + logging.info('next_design:%s' % next_design.route_id.name) + logging.info('next_design面:%s' % next_design.panel) + logging.info('design:%s' % design.route_id.name) + logging.info('design面:%s' % design.panel) + if next_design == design: + break + if design.panel != next_design.panel and routing_type not in ['解除装夹']: + raise UserError('【加工面】为%s的标准工序里含有其他加工面的工序,请调整后重试' % design.panel) + if design.panel == next_design.panel: + if (routing_type == '装夹预调' and next_design_routing_type == '解除装夹') or ( + routing_type == 'CNC加工' and next_design_routing_type == '装夹预调'): + raise UserError('【加工面】为%s的标准工序顺序有误,请调整后重试' % design.panel) + return True + def action_check(self): """ 审核启用 diff --git a/sf_manufacturing/models/mrp_routing_workcenter.py b/sf_manufacturing/models/mrp_routing_workcenter.py index ef451df7..2916bdce 100644 --- a/sf_manufacturing/models/mrp_routing_workcenter.py +++ b/sf_manufacturing/models/mrp_routing_workcenter.py @@ -14,7 +14,7 @@ class ResMrpRoutingWorkcenter(models.Model): ('表面工艺', '表面工艺') ], string="工序类型") routing_tag = fields.Selection([ - ('Standard', '标准'), + ('standard', '标准'), ('special', '特殊') ], string="标签") is_repeat = fields.Boolean('重复', default=False) @@ -23,6 +23,7 @@ class ResMrpRoutingWorkcenter(models.Model): bom_id = fields.Many2one('mrp.bom', required=False) surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺") reserved_duration = fields.Float('预留时长', default=30, tracking=True) + def get_no(self): international_standards = self.search( [('code', '!=', ''), ('active', 'in', [True, False])], @@ -79,3 +80,13 @@ class ResMrpRoutingWorkcenter(models.Model): else: workcenter_id = workcenter_ids[0] return workcenter_id + + @api.model + def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None): + if self._context.get('production_id'): + technology_design = self.env['sf.technology.design'].search( + [('production_id', '=', self._context.get('production_id'))]) + route_ids = [t.route_id.id for t in technology_design] + domain = [('id', 'not in', route_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/sf_technology_design.py b/sf_manufacturing/models/sf_technology_design.py index afb5f05b..e5ce0c69 100644 --- a/sf_manufacturing/models/sf_technology_design.py +++ b/sf_manufacturing/models/sf_technology_design.py @@ -6,22 +6,23 @@ class sf_technology_design(models.Model): _name = 'sf.technology.design' _description = "工艺设计" - name = fields.Char('工序') + route_id = fields.Many2one('mrp.routing.workcenter', '工序') panel = fields.Char('加工面') sequence = fields.Integer('序号') - time_cycle_manual = fields.Float('预计时长') + routing_tag = fields.Selection(related='route_id.routing_tag', string='标签', store=True) + time_cycle_manual = fields.Float(related='route_id.time_cycle_manual', string='预计时长') production_id = fields.Many2one('mrp.production') is_auto = fields.Boolean('是否自动生成', default=False) active = fields.Boolean('有效', default=True) - def json_technology_design_str(self, k, route_name, time_cycle_manual, i): + def json_technology_design_str(self, k, route, i): workorders_values_str = [0, '', { - 'name': route_name, + 'route_id': route.id, 'panel': k, 'sequence': i, - 'is_auto': True, - 'time_cycle_manual': time_cycle_manual}] + 'is_auto': True}] return workorders_values_str def unlink_technology_design(self): self.active = False + diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 64c89d46..70dbdf68 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -367,10 +367,7 @@ class StockRule(models.Model): for route in product_routing_workcenter: i += 1 technology_design_values.append( - self.env['sf.technology.design'].json_technology_design_str(k, - route.route_workcenter_id.name, - route.route_workcenter_id.time_cycle_manual, - i)) + self.env['sf.technology.design'].json_technology_design_str(k, route, i)) surface_technics_arr = [] route_workcenter_arr = [] for process_param in production.product_id.product_model_type_id.surface_technics_routing_tmpl_ids.filtered( @@ -403,8 +400,7 @@ class StockRule(models.Model): ('id', 'in', route_workcenter_arr)]) technology_design_values.append( self.env['sf.technology.design'].json_technology_design_str(k, - process_parameter.display_name, - route_production_process.time_cycle_manual, + route_production_process, i)) productions.technology_design_ids = technology_design_values @@ -624,12 +620,12 @@ class StockPicking(models.Model): item.telephone_of_delivery = sale_id.telephone_of_delivery item.address_of_delivery = sale_id.address_of_delivery - bom = self.env['mrp.bom'].sudo().search([('bom_line_ids.product_id', '=', self.move_ids.product_id.id)]) - if bom: - if item.picking_type_id.sequence_code == 'DL': - item.retrospect_ref = bom.product_tmpl_id.default_code - elif item.picking_type_id.sequence_code in ['INT', 'PC']: - item.retrospect_ref = bom.product_tmpl_id.name + # bom = self.env['mrp.bom'].sudo().search([('bom_line_ids.product_id', '=', self.move_ids.product_id.id)]) + # if bom: + # if item.picking_type_id.sequence_code == 'DL': + # item.retrospect_ref = bom.product_tmpl_id.default_code + # elif item.picking_type_id.sequence_code in ['INT', 'PC']: + # item.retrospect_ref = bom.product_tmpl_id.name # 设置外协出入单的名称 def _get_name_Res(self, rescode): diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index 42b68eae..1899aad2 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -114,12 +114,18 @@ string="验证" type="object" class="oe_highlight" confirm="There are no components to consume. Are you still sure you want to continue?" data-hotkey="g" groups="sf_base.group_sf_mrp_user"/> + + From 2798ce6183bc6a571f8fcc3aa69e03adde44b926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Fri, 8 Nov 2024 16:23:34 +0800 Subject: [PATCH 019/201] =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__init__.py | 14 ++ .../__manifest__.py | 26 +++ .../controllers/__init__.py | 2 + .../controllers/main.py | 52 ++++++ .../data/product_data.xml | 85 ++++++++++ .../data/stock_routes.xml | 32 ++++ .../models/__init__.py | 3 + .../models/product_template.py | 31 ++++ .../models/sale_order.py | 156 ++++++++++++++++++ .../security/ir.model.access.csv | 8 + .../views/product_product_views.xml | 15 ++ .../views/sale_order_views.xml | 104 ++++++++++++ 12 files changed, 528 insertions(+) create mode 100644 jikimo_sale_multiple_supply_methods/__init__.py create mode 100644 jikimo_sale_multiple_supply_methods/__manifest__.py create mode 100644 jikimo_sale_multiple_supply_methods/controllers/__init__.py create mode 100644 jikimo_sale_multiple_supply_methods/controllers/main.py create mode 100644 jikimo_sale_multiple_supply_methods/data/product_data.xml create mode 100644 jikimo_sale_multiple_supply_methods/data/stock_routes.xml create mode 100644 jikimo_sale_multiple_supply_methods/models/__init__.py create mode 100644 jikimo_sale_multiple_supply_methods/models/product_template.py create mode 100644 jikimo_sale_multiple_supply_methods/models/sale_order.py create mode 100644 jikimo_sale_multiple_supply_methods/security/ir.model.access.csv create mode 100644 jikimo_sale_multiple_supply_methods/views/product_product_views.xml create mode 100644 jikimo_sale_multiple_supply_methods/views/sale_order_views.xml diff --git a/jikimo_sale_multiple_supply_methods/__init__.py b/jikimo_sale_multiple_supply_methods/__init__.py new file mode 100644 index 00000000..d5b81964 --- /dev/null +++ b/jikimo_sale_multiple_supply_methods/__init__.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +from . import models +from . import controllers + +from odoo import api, SUPERUSER_ID + +def _set_init_product_active_false(cr, registry): + env = api.Environment(cr, SUPERUSER_ID, {}) + # 获取所有需要设置的产品模板 + env.ref('jikimo_sale_multiple_supply_methods.product_template_purchase').product_variant_id.write({'active': False}) + env.ref('jikimo_sale_multiple_supply_methods.product_template_manual_processing').product_variant_id.write({'active': False}) + env.ref('jikimo_sale_multiple_supply_methods.product_template_default').product_variant_id.write({'active': False}) + env.ref('jikimo_sale_multiple_supply_methods.product_template_raw_material_customer_provided').product_variant_id.write({'active': False}) + env.ref('jikimo_sale_multiple_supply_methods.product_template_outsourcing').product_variant_id.write({'active': False}) diff --git a/jikimo_sale_multiple_supply_methods/__manifest__.py b/jikimo_sale_multiple_supply_methods/__manifest__.py new file mode 100644 index 00000000..dec1cf62 --- /dev/null +++ b/jikimo_sale_multiple_supply_methods/__manifest__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +{ + 'name': '机企猫 多供货方式', + 'version': '16.0.1.0.0', + 'summary': """ 报价单提供(自动化产线加工/人工线下加工/外购/委外加工)多种供货方式选择 """, + 'author': 'fox', + 'website': '', + 'category': '', + 'depends': ['product', 'sf_dlm_management', 'sale_stock'], + "data": [ + 'security/ir.model.access.csv', + 'data/stock_routes.xml', + 'data/product_data.xml', + 'views/sale_order_views.xml', + 'views/product_product_views.xml', + ],'assets': { + # 'web.assets_backend': [ + # 'jikimo_sale_multiple_supply_methods/static/src/**/*' + # ], + }, + 'post_init_hook': '_set_init_product_active_false', + 'application': True, + 'installable': True, + 'auto_install': False, + 'license': 'LGPL-3', +} diff --git a/jikimo_sale_multiple_supply_methods/controllers/__init__.py b/jikimo_sale_multiple_supply_methods/controllers/__init__.py new file mode 100644 index 00000000..cd4d6a8b --- /dev/null +++ b/jikimo_sale_multiple_supply_methods/controllers/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import main \ No newline at end of file diff --git a/jikimo_sale_multiple_supply_methods/controllers/main.py b/jikimo_sale_multiple_supply_methods/controllers/main.py new file mode 100644 index 00000000..9c20e687 --- /dev/null +++ b/jikimo_sale_multiple_supply_methods/controllers/main.py @@ -0,0 +1,52 @@ +import logging +import json +from odoo import http +from odoo.http import request +from odoo.addons.sf_bf_connect.controllers.controllers import Sf_Bf_Connect + +_logger = logging.getLogger(__name__) + +class JikimoSaleRoutePicking(Sf_Bf_Connect): + + @http.route('/api/bfm_process_order/list', type='http', auth='sf_token', methods=['GET', 'POST'], csrf=False, + cors="*") + def get_bfm_process_order_list(self, **kw): + """ + 接收业务平台加工订单分配工厂时传送来的订单数据并生成销售订单和产品及坯料 + :param kw: + :return: + """ + res = {'status': 1, 'factory_order_no': ''} + # _logger.info('get_bfm_process_order_list:%s' % kw['order_number']) + try: + product_tmpl_id = request.env.ref('jikimo_sale_multiple_supply_methods.product_template_default').sudo() + product_id = request.env['product.product'].sudo().search( + [('product_tmpl_id', '=', product_tmpl_id.id), ('active', '=', False)], + limit=1, + order='id asc' + ) + company_id = request.env.ref('base.main_company').sudo() + bfm_process_order_list = json.loads(kw['bfm_process_order_list']) + order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create( + company_id, kw['delivery_name'], kw['delivery_telephone'], kw['delivery_address'], + kw['delivery_end_date'], kw['payments_way'], kw['pay_way'], state='draft') + i = 1 + # 给sale_order的default_code字段赋值 + aa = request.env['sale.order'].sudo().search([('name', '=', order_id.name)]) + _logger.info('get_bfm_process_or===================================:%s' % order_id.name) + aa.default_code = kw['order_number'] + if kw.get('logistics_way'): + aa.logistics_way = kw['logistics_way'] + _logger.info('get_bfm_process_order_listaaaaaaaaaaaaaaaaaaaaaaaaaaaa================:%s' % aa.default_code) + for item in bfm_process_order_list: + product = request.env['product.template'].sudo().product_create(product_id, item, order_id, + kw['order_number'], i) + order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item) + i += 1 + res['factory_order_no'] = order_id.name + except Exception as e: + _logger.info('get_bfm_process_order_list error:%s' % e) + res['status'] = -1 + res['message'] = '工厂创建销售订单和产品失败,请联系管理员' + request.cr.rollback() + return json.JSONEncoder().encode(res) diff --git a/jikimo_sale_multiple_supply_methods/data/product_data.xml b/jikimo_sale_multiple_supply_methods/data/product_data.xml new file mode 100644 index 00000000..6f804ad5 --- /dev/null +++ b/jikimo_sale_multiple_supply_methods/data/product_data.xml @@ -0,0 +1,85 @@ + + + + + 人工线下加工模板 + + + + delivery + product + false + + + + true + serial + true + true + + + + 成品外购模板 + + + + serial + product + + + + true + + + + 成品委外加工模板 + + + + serial + product + + + + true + + + + 成品初始化模板 + + + + serial + product + + + + true + + + + + + + + + 坯料客供料模板 + + + + false + serial + product + + + + + + + \ No newline at end of file diff --git a/jikimo_sale_multiple_supply_methods/data/stock_routes.xml b/jikimo_sale_multiple_supply_methods/data/stock_routes.xml new file mode 100644 index 00000000..de4c2106 --- /dev/null +++ b/jikimo_sale_multiple_supply_methods/data/stock_routes.xml @@ -0,0 +1,32 @@ + + + + + 带料加工 + true + true + + 16 + + + + 客供料入库 + incoming + true + + DL + + + + + + + 带料收货 + + + + + pull + + + \ No newline at end of file diff --git a/jikimo_sale_multiple_supply_methods/models/__init__.py b/jikimo_sale_multiple_supply_methods/models/__init__.py new file mode 100644 index 00000000..28c7877f --- /dev/null +++ b/jikimo_sale_multiple_supply_methods/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +from . import product_template +from . import sale_order diff --git a/jikimo_sale_multiple_supply_methods/models/product_template.py b/jikimo_sale_multiple_supply_methods/models/product_template.py new file mode 100644 index 00000000..e5b3ba0e --- /dev/null +++ b/jikimo_sale_multiple_supply_methods/models/product_template.py @@ -0,0 +1,31 @@ +from odoo import models, fields, api + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + is_manual_processing = fields.Boolean(string='人工线下加工') + is_customer_provided = fields.Boolean(string='客供料') + + def product_create(self, product_id, item, order_id, order_number, i): + product_id = super(ProductTemplate, self).product_create(product_id, item, order_id, order_number, i) + product_id.product_tmpl_id.is_customer_provided = item['is_incoming_material'] + return product_id + + + def copy_template(self, product_template_id): + if not isinstance(product_template_id, ProductTemplate): + raise ValueError('%s必须是ProductTemplate类型' % product_template_id) + + self.route_ids = product_template_id.route_ids + self.categ_id = product_template_id.categ_id + self.invoice_policy = product_template_id.invoice_policy + self.detailed_type = product_template_id.detailed_type + self.purchase_ok = product_template_id.purchase_ok + self.uom_id = product_template_id.uom_id + self.uom_po_id = product_template_id.uom_po_id + self.company_id = product_template_id.company_id + self.single_manufacturing = product_template_id.single_manufacturing + self.tracking = product_template_id.tracking + self.is_bfm = product_template_id.is_bfm + self.is_manual_processing = product_template_id.is_manual_processing + self.seller_ids = product_template_id.seller_ids diff --git a/jikimo_sale_multiple_supply_methods/models/sale_order.py b/jikimo_sale_multiple_supply_methods/models/sale_order.py new file mode 100644 index 00000000..1db9541c --- /dev/null +++ b/jikimo_sale_multiple_supply_methods/models/sale_order.py @@ -0,0 +1,156 @@ +import logging +import json +from odoo import models, fields, api +from odoo.exceptions import UserError + +_logger = logging.getLogger(__name__) + +class SaleOrder(models.Model): + _inherit = 'sale.order' + + state = fields.Selection([ + ('draft', "报价"), + ('sent', "报价已发送"), + ('supply method', "供货方式待确认"), + ('sale', "销售订单"), + ('done', "已锁定"), + ('cancel', "已取消"), + ]) + + def confirm_to_supply_method(self): + self.state = 'supply method' + + def action_confirm(self): + for line in self.order_line: + if not line.supply_method: + raise UserError('请先选择供货方式') + bom_type = '' + # 根据供货方式修改成品模板 + if line.supply_method == 'automation': + bom_type = 'normal' + product_template_id = self.env.ref('sf_dlm.product_template_sf').sudo().product_tmpl_id + elif line.supply_method == 'outsourcing': + bom_type = 'subcontract' + product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_outsourcing').sudo() + elif line.supply_method == 'purchase': + product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_purchase').sudo() + elif line.supply_method == 'manual': + bom_type = 'normal' + product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_manual_processing').sudo() + + # 复制成品模板上的属性 + line.product_id.product_tmpl_id.copy_template(product_template_id) + + order_id = self + product = line.product_id + # 拼接方法需要的item结构 + item = { + 'texture_code': product.materials_id.materials_no, + 'texture_type_code': product.materials_type_id.materials_no, + 'model_long': product.length, + 'model_width': product.width, + 'model_height': product.height, + 'price': product.list_price, + } + # 成品供货方式为采购则不生成bom + if line.supply_method != 'purchase': + bom_data = self.env['mrp.bom'].with_user(self.env.ref("base.user_admin")).get_bom(product) + _logger.info('bom_data:%s' % bom_data) + if bom_data: + bom = self.env['mrp.bom'].with_user(self.env.ref("base.user_admin")).bom_create(product, 'normal', False) + bom.with_user(self.env.ref("base.user_admin")).bom_create_line_has(bom_data) + else: + # 当成品上带有客供料选项时,生成坯料时选择“客供料”路线 + if line.is_incoming_material: + # 将成品模板的内容复制到成品上 + embryo_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_raw_material_customer_provided').sudo() + embryo_id = self.env['product.product'].search( + [('product_tmpl_id', '=', embryo_template_id.id), ('active', '=', False)], + limit=1, + order='id asc' + ) + # 创建坯料,客供料的批量不需要创建bom + material_customer_provided_embryo = self.env['product.template'].sudo().no_bom_product_create( + embryo_id, + item, + order_id, 'material_customer_provided', 0, product) + # 成品配置bom + product_bom_material_customer_provided = self.env['mrp.bom'].with_user( + self.env.ref("base.user_admin")).bom_create( + product, bom_type, True) + product_bom_material_customer_provided.with_user(self.env.ref("base.user_admin")).bom_create_line_has( + material_customer_provided_embryo) + elif line.product_id.materials_type_id.gain_way == '自加工': + self_machining_id = self.env.ref('sf_dlm.product_embryo_sf_self_machining').sudo() + # 创建坯料 + self_machining_embryo = self.env['product.template'].sudo().no_bom_product_create( + self_machining_id, + item, + order_id, 'self_machining', 0, product) + # 创建坯料的bom + self_machining_bom = self.env['mrp.bom'].with_user( + self.env.ref("base.user_admin")).bom_create( + self_machining_embryo, 'normal', False) + # 创建坯料里bom的组件 + self_machining_bom_line = self_machining_bom.with_user( + self.env.ref("base.user_admin")).bom_create_line( + self_machining_embryo) + if not self_machining_bom_line: + raise UserError('该订单模型的材料型号暂未有原材料,请先配置再进行分配') + # 产品配置bom + product_bom_self_machining = self.env['mrp.bom'].with_user( + self.env.ref("base.user_admin")).bom_create( + product, bom_type, True) + product_bom_self_machining.with_user(self.env.ref("base.user_admin")).bom_create_line_has( + self_machining_embryo) + elif line.product_id.materials_type_id.gain_way == '外协': + outsource_id = self.env.ref('sf_dlm.product_embryo_sf_outsource').sudo() + # 创建坯料 + outsource_embryo = self.env['product.template'].sudo().no_bom_product_create(outsource_id, + item, + order_id, + 'subcontract', + 0, product) + if outsource_embryo == -3: + raise UserError('该订单模型的材料型号暂未设置获取方式和供应商,请先配置再进行分配') + # 创建坯料的bom + outsource_bom = self.env['mrp.bom'].with_user(self.env.ref("base.user_admin")).bom_create( + outsource_embryo, + 'subcontract', True) + # 创建坯料的bom的组件 + outsource_bom_line = outsource_bom.with_user( + self.env.ref("base.user_admin")).bom_create_line(outsource_embryo) + if not outsource_bom_line: + raise UserError('该订单模型的材料型号暂未有原材料,请先配置再进行分配') + # 产品配置bom + product_bom_outsource = self.env['mrp.bom'].with_user( + self.env.ref("base.user_admin")).bom_create(product, bom_type, True) + product_bom_outsource.with_user(self.env.ref("base.user_admin")).bom_create_line_has( + outsource_embryo) + elif line.product_id.materials_type_id.gain_way == '采购': + purchase_id = self.env.ref('sf_dlm.product_embryo_sf_purchase').sudo() + purchase_embryo = self.env['product.template'].sudo().no_bom_product_create(purchase_id, + item, + order_id, + 'purchase', i, + product) + if purchase_embryo == -3: + raise UserError('该订单模型的材料型号暂未设置获取方式和供应商,请先配置再进行分配') + else: + # 产品配置bom + product_bom_purchase = self.env['mrp.bom'].with_user( + self.env.ref("base.user_admin")).bom_create(product, bom_type, True) + product_bom_purchase.with_user(self.env.ref("base.user_admin")).bom_create_line_has( + purchase_embryo) + return super(SaleOrder, self).action_confirm() + +class SaleOrderLine(models.Model): + _inherit = 'sale.order.line' + + # 供货方式 + supply_method = fields.Selection([ + ('automation', "自动化产线加工"), + ('manual', "人工线下加工"), + ('purchase', "外购"), + ('outsourcing', "委外加工"), + ], string='供货方式') diff --git a/jikimo_sale_multiple_supply_methods/security/ir.model.access.csv b/jikimo_sale_multiple_supply_methods/security/ir.model.access.csv new file mode 100644 index 00000000..3b276af9 --- /dev/null +++ b/jikimo_sale_multiple_supply_methods/security/ir.model.access.csv @@ -0,0 +1,8 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_sale_order_group_production_engineer,sale.order_group_production_engineer,sale.model_sale_order,sf_base.group_production_engineer,1,1,0,0 +access_sale_order_line_group_production_engineer,sale_order_line_group_production_engineer,sale.model_sale_order_line,sf_base.group_production_engineer,1,1,0,0 +access_product_product_group_production_engineer,product_product_group_production_engineer,product.model_product_product,sf_base.group_production_engineer,1,0,0,0 +access_product_template_group_production_engineer,product_template_group_production_engineer,product.model_product_template,sf_base.group_production_engineer,1,0,0,0 +access_stock_picking_group_production_engineer,stock_picking_group_production_engineer,stock.model_stock_picking,sf_base.group_production_engineer,1,0,0,0 +access_stock_move_group_production_engineer,stock_move_group_production_engineer,stock.model_stock_move,sf_base.group_production_engineer,1,0,0,0 +access_mrp_bom_group_production_engineer,mrp_bom_group_production_engineer,mrp.model_mrp_bom,sf_base.group_production_engineer,1,0,0,0 \ No newline at end of file diff --git a/jikimo_sale_multiple_supply_methods/views/product_product_views.xml b/jikimo_sale_multiple_supply_methods/views/product_product_views.xml new file mode 100644 index 00000000..e3f896b5 --- /dev/null +++ b/jikimo_sale_multiple_supply_methods/views/product_product_views.xml @@ -0,0 +1,15 @@ + + + + view.product.template.form.inherit.sf + product.template + + + + + + + + + + \ No newline at end of file diff --git a/jikimo_sale_multiple_supply_methods/views/sale_order_views.xml b/jikimo_sale_multiple_supply_methods/views/sale_order_views.xml new file mode 100644 index 00000000..3021f301 --- /dev/null +++ b/jikimo_sale_multiple_supply_methods/views/sale_order_views.xml @@ -0,0 +1,104 @@ + + + + view.sale.order.form.inherit.sf + + sale.order + + + + + + + + + + view.sale.order.form.inherit.supply.method + + sale.order + + + {'invisible': [('state', '!=', 'draft')]} + confirm_to_supply_method + + + + + - - + + attrs="{'invisible': [('state', '!=', 'technology_to_confirmed')]}">