From a49a24e9e691d6884fa0c830cc50bd18438800bd Mon Sep 17 00:00:00 2001
From: gqh
Date: Mon, 7 Nov 2022 10:59:22 +0800
Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_base/__manifest__.py | 9 +-
sf_base/models/__init__.py | 7 +-
sf_base/security/ir.model.access.csv | 5 --
sf_base/views/menu_view.xml | 14 +--
sf_base/views/mrs_base_view.xml | 66 +-------------
sf_base/views/mrs_common_view.xml | 33 +++----
.../views/sale_process_order_view.xml | 30 +++----
sf_bpm_api/__manifest__.py | 7 +-
sf_bpm_api/data/product_data.xml | 16 ++++
sf_bpm_api/models/__init__.py | 3 +-
sf_bpm_api/models/product_template.py | 86 +++++++++++++++++++
sf_bpm_api/models/sale_order.py | 34 ++++++++
sf_bpm_api/security/ir.model.access.csv | 3 +
sf_bpm_api/views/product_template_view.xml | 69 +++++++++++++++
sf_bpm_api/views/sale_order_view.xml | 15 ++++
sf_route_workcenter/models/workcenter.py | 25 +++---
sf_route_workcenter/views/sf_tray_view.xml | 3 +-
sf_route_workcenter/views/sf_workorder.xml | 80 +++++++++++------
18 files changed, 336 insertions(+), 169 deletions(-)
create mode 100644 sf_bpm_api/data/product_data.xml
create mode 100644 sf_bpm_api/models/product_template.py
create mode 100644 sf_bpm_api/models/sale_order.py
create mode 100644 sf_bpm_api/views/product_template_view.xml
create mode 100644 sf_bpm_api/views/sale_order_view.xml
diff --git a/sf_base/__manifest__.py b/sf_base/__manifest__.py
index 94c9da55..77165cde 100644
--- a/sf_base/__manifest__.py
+++ b/sf_base/__manifest__.py
@@ -10,18 +10,13 @@
""",
'category': 'YZ',
'website': 'https://www.sf.jikimo.com',
- 'depends': ['account', 'base', 'mrp', 'sale'],
+ 'depends': ['account', 'base', 'mrp'],
'data': [
'security/group_security.xml',
'security/ir.model.access.csv',
- 'data/product_data.xml',
- # 'data/process_data.xml',
'views/mrs_base_view.xml',
'views/mrs_common_view.xml',
- 'views/menu_view.xml',
- 'views/mrp_routing_workcenter_view.xml',
- 'views/sale_order_view.xml',
- 'views/product_template_view.xml',
+ "views/menu_view.xml"
],
'demo': [
diff --git a/sf_base/models/__init__.py b/sf_base/models/__init__.py
index 0f189de6..27b447be 100644
--- a/sf_base/models/__init__.py
+++ b/sf_base/models/__init__.py
@@ -1,5 +1,2 @@
-from . import sf_base
-from . import sf_common
-from . import product_template
-from . import sale_order
-from . import process
+from. import sf_base
+from. import sf_common
diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv
index ec0a074a..930fcd07 100644
--- a/sf_base/security/ir.model.access.csv
+++ b/sf_base/security/ir.model.access.csv
@@ -13,12 +13,7 @@ access_mrs_production_materials,mrs_production_materials,model_mrs_production_ma
access_mrs_materials_model,mrs_materials_model,model_mrs_materials_model,base.group_user,1,1,1,1
access_mrs_processing_technology,mrs_processing_technology,model_mrs_processing_technology,base.group_user,1,1,1,1
access_sf_tray,sf_tray,model_sf_tray,base.group_user,1,1,1,1
-<<<<<<< HEAD
access_cnc_processing,cnc_processing,model_cnc_processing,base.group_user,1,1,1,1
-=======
-access_sf_model_type,sf_model_type,model_sf_model_type,base.group_user,1,1,1,1
-access_sf_model_type_routing_sort,sf_model_type_routing_sort,model_sf_model_type_routing_sort,base.group_user,1,1,1,1
->>>>>>> 8e337dda97a98a9a8d0a892a2c39bc076640f6ac
diff --git a/sf_base/views/menu_view.xml b/sf_base/views/menu_view.xml
index 4babedb1..42c9602c 100644
--- a/sf_base/views/menu_view.xml
+++ b/sf_base/views/menu_view.xml
@@ -142,13 +142,13 @@
action="action_mrs_machine_control_system"/>
-
+
+
+
+
+
+
+
diff --git a/sf_base/views/mrs_base_view.xml b/sf_base/views/mrs_base_view.xml
index b7f61d4f..1d6aeaf3 100644
--- a/sf_base/views/mrs_base_view.xml
+++ b/sf_base/views/mrs_base_view.xml
@@ -355,11 +355,11 @@
-
- #------------------模型类型------------------
-
-
- search.sf.model.type
- sf.model.type
-
-
-
-
-
-
-
-
- tree.sf.model.type
- sf.model.type
-
-
-
-
-
-
-
-
- form.sf.model.type
- sf.model.type
-
-
-
-
-
-
- 模型类型
- ir.actions.act_window
- sf.model.type
- tree,form
-
-
- [模型类型] 还没有哦!点左上角的[创建]按钮,沙发归你了!
-
-
-
-
-
\ No newline at end of file
diff --git a/sf_base/views/mrs_common_view.xml b/sf_base/views/mrs_common_view.xml
index f57d48a2..4f9374e1 100644
--- a/sf_base/views/mrs_common_view.xml
+++ b/sf_base/views/mrs_common_view.xml
@@ -277,23 +277,10 @@
#------------------托盘------------------
-
- 托盘
- ir.actions.act_window
- sf.tray
- tree,form
-
-
- 创建托盘吧
-
-
-
-
sf.tray.search
sf.tray
-<<<<<<< HEAD
@@ -305,14 +292,6 @@
-=======
-
-
-
-
-
-
->>>>>>> 8e337dda97a98a9a8d0a892a2c39bc076640f6ac
@@ -347,7 +326,17 @@
-
+
+ 托盘
+ ir.actions.act_window
+ sf.tray
+ tree,form
+
+
+ 创建托盘吧
+
+
+
\ No newline at end of file
diff --git a/sf_bf_connect/views/sale_process_order_view.xml b/sf_bf_connect/views/sale_process_order_view.xml
index 188a2767..898ade1b 100644
--- a/sf_bf_connect/views/sale_process_order_view.xml
+++ b/sf_bf_connect/views/sale_process_order_view.xml
@@ -1,18 +1,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ sale.order
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sf_bpm_api/__manifest__.py b/sf_bpm_api/__manifest__.py
index 0447a76b..b659bd14 100644
--- a/sf_bpm_api/__manifest__.py
+++ b/sf_bpm_api/__manifest__.py
@@ -10,10 +10,11 @@
""",
'category': 'sf',
'website': 'https://www.sf.cs.jikimo.com',
- 'depends': ['sale', 'sf_base', 'mrp'],
+ 'depends': ['sale', 'sf_base'],
'data': [
- 'security/group_security.xml',
- 'security/ir.model.access.csv',
+ 'data/product_data.xml',
+ 'views/product_template_view.xml',
+ 'views/sale_order_view.xml'
],
'demo': [
],
diff --git a/sf_bpm_api/data/product_data.xml b/sf_bpm_api/data/product_data.xml
new file mode 100644
index 00000000..53fb6216
--- /dev/null
+++ b/sf_bpm_api/data/product_data.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ CNC加工产品模板
+
+ delivery
+ product
+ false
+
+
+
+ false
+
+
+
\ No newline at end of file
diff --git a/sf_bpm_api/models/__init__.py b/sf_bpm_api/models/__init__.py
index 0d9a2937..4c183668 100644
--- a/sf_bpm_api/models/__init__.py
+++ b/sf_bpm_api/models/__init__.py
@@ -1,5 +1,6 @@
+from . import sale_order
+from . import product_template
from . import http
from . import models
-
diff --git a/sf_bpm_api/models/product_template.py b/sf_bpm_api/models/product_template.py
new file mode 100644
index 00000000..08f2237c
--- /dev/null
+++ b/sf_bpm_api/models/product_template.py
@@ -0,0 +1,86 @@
+from odoo import models, fields
+from odoo.exceptions import ValidationError
+
+
+class ResProductTemplate(models.Model):
+ _inherit = 'product.template'
+
+ # 模型的长,宽,高,体积,精度,材料
+ model_long = fields.Float('长[mm]', digits=(16, 3))
+ model_width = fields.Float('宽[mm]', digits=(16, 3))
+ model_height = fields.Float('高[mm]', digits=(16, 3))
+ model_volume = fields.Float('体积[mm³]', digits=(16, 3))
+ model_precision = fields.Float('精度要求', digits=(16, 3))
+ model_materials_id = fields.Many2one('mrs.production.materials', string='材料')
+ model_materials_type_id = fields.Many2one('mrs.materials.model', string='型号')
+ # 胚料的长,宽,高
+ embryo_long = fields.Float('长[mm]', digits=(16, 3))
+ embryo_width = fields.Float('宽[mm]', digits=(16, 3))
+ embryo_height = fields.Float('高[mm]', digits=(16, 3))
+ embryo_materials_id = fields.Many2one('mrs.production.materials', string='材料')
+ embryo_materials_type_id = fields.Many2one('mrs.materials.model', string='型号')
+
+ # 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
+ def product_create(self, product_id, item, order_id, order_number, i):
+ copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
+ copy_product_id.product_tmpl_id.active = True
+ vals = {
+ 'name': '%s-%s' % (order_id.name, i),
+ 'model_long': item['model_long'],
+ 'model_width': item['model_width'],
+ 'model_height': item['model_height'],
+ 'model_volume': item['model_volume'],
+ 'list_price': item['price'],
+ 'model_materials_id': self.env['mrs.production.materials'].search(
+ [('materials_no', '=', item['texture_code'])]).id,
+ 'model_materials_type_id': self.env['mrs.materials.model'].search(
+ [('materials_no', '=', item['texture_type_code'])]).id,
+ 'default_code': '%s-%s' % (order_number, i),
+ 'barcode': item['barcode'],
+ 'active': True
+ }
+ copy_product_id.sudo().write(vals)
+ return copy_product_id
+
+
+class ResProductCategory(models.Model):
+ _inherit = "product.category"
+
+ is_embryo = fields.Boolean('胚料')
+
+
+class ResMrpBom(models.Model):
+ _inherit = 'mrp.bom'
+
+ # 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
+ def bom_create(self, product):
+ bom_id = self.env['mrp.bom'].create({
+ 'product_tmpl_id': product.product_tmpl_id.id,
+ 'type': 'normal',
+ 'product_qty': 1,
+ 'product_uom_id': 1
+ })
+ return bom_id
+
+ # 生成产品BOM匹配胚料,胚料的匹配规则:
+ # 一、匹配的胚料类别需要带有胚料的标签;
+ # 二、胚料的材料型号与生成产品的材料型号一致;
+ # 三、胚料的长宽高均要大于模型的长宽高;
+ # 四、如果匹配成功多个胚料,则选取体积最小的胚料;
+ def bom_create_Line(self, product):
+ embryo = self.env['product.product'].search(
+ [('categ_id.is_embryo', '=', True), ('embryo_materials_type_id', '=', product.model_materials_type_id.id),
+ ('embryo_long', '>', product.model_long), ('embryo_width', '>', product.model_width),
+ ('embryo_height', '>', product.model_height)
+ ],
+ limit=1,
+ order='volume desc'
+ )
+ vals = {
+ 'bom_id': self.id,
+ 'product_id': embryo.id,
+ 'product_tmpl_id': embryo.product_tmpl_id.id,
+ 'product_qty': 1,
+ 'product_uom_id': 1
+ }
+ return self.env['mrp.bom.line'].create(vals)
diff --git a/sf_bpm_api/models/sale_order.py b/sf_bpm_api/models/sale_order.py
new file mode 100644
index 00000000..1618a4e3
--- /dev/null
+++ b/sf_bpm_api/models/sale_order.py
@@ -0,0 +1,34 @@
+from odoo import models, fields
+from odoo.exceptions import ValidationError
+import datetime
+
+
+class ReSaleOrder(models.Model):
+ _inherit = 'sale.order'
+
+ deadline_of_delivery = fields.Date('交货截止日期')
+
+ # 业务平台分配工厂后在智能工厂先创建销售订单
+ def sale_order_create(self, deadline_of_delivery, company_id):
+ now_time = datetime.datetime.now()
+ order_id = self.env['sale.order'].sudo().create({
+ 'company_id': company_id.id,
+ 'date_order': now_time,
+ 'name': self.env['ir.sequence'].next_by_code('sale.order', sequence_date=now_time),
+ 'partner_id': 8,
+ 'state': 'sale',
+ 'user_id': 6,
+ 'deadline_of_delivery': deadline_of_delivery
+ })
+ return order_id
+
+ # 业务平台分配工厂时在创建完产品后再创建销售明细信息
+ def sale_order_create_line(self, product, item):
+ vals = {
+ 'order_id': self.id,
+ 'product_id': product.id,
+ 'name': '%s/%s/%s/%s/%s' % (item['model_long'], item['model_width'], item['model_height'], item['model_volume'], product.model_materials_id.name),
+ 'price_unit': item['price'],
+ 'product_uom_qty': item['number']
+ }
+ return self.env['sale.order.line'].create(vals)
diff --git a/sf_bpm_api/security/ir.model.access.csv b/sf_bpm_api/security/ir.model.access.csv
index 08145a00..963679d4 100644
--- a/sf_bpm_api/security/ir.model.access.csv
+++ b/sf_bpm_api/security/ir.model.access.csv
@@ -1,2 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+
+
+
diff --git a/sf_bpm_api/views/product_template_view.xml b/sf_bpm_api/views/product_template_view.xml
new file mode 100644
index 00000000..406330e3
--- /dev/null
+++ b/sf_bpm_api/views/product_template_view.xml
@@ -0,0 +1,69 @@
+
+
+
+
+ product.template.form.inherit.sf
+ product.template
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ product.category.form.inherit.sf
+ product.category
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sf_bpm_api/views/sale_order_view.xml b/sf_bpm_api/views/sale_order_view.xml
new file mode 100644
index 00000000..58abd5be
--- /dev/null
+++ b/sf_bpm_api/views/sale_order_view.xml
@@ -0,0 +1,15 @@
+
+
+
+
+ sale.order.form.inherit.sf
+ sale.order
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sf_route_workcenter/models/workcenter.py b/sf_route_workcenter/models/workcenter.py
index 4340b465..6472598f 100644
--- a/sf_route_workcenter/models/workcenter.py
+++ b/sf_route_workcenter/models/workcenter.py
@@ -8,8 +8,7 @@ import qrcode
from io import BytesIO
from odoo import api, fields, models
-import barcode
-from barcode.writer import ImageWriter
+
from pystrich.code128 import Code128Encoder
from odoo.exceptions import UserError
@@ -20,7 +19,7 @@ class CNCprocessing(models.Model):
_inherit = 'cnc.processing'
_description = "CNC加工"
- workorder_id = fields.Many2one('mrp.workorder' ,string="工单")
+ workorder_id = fields.Many2one('mrp.workorder', string="工单")
class Tray(models.Model):
@@ -86,21 +85,15 @@ class MrpWorkOrder(models.Model):
_inherit = 'mrp.workorder'
_description = '工单'
- tray_id = fields.Many2one('sf.tray', string="托盘")
- tray_code = fields.Char(
- string='托盘编码',
- related='tray_id.code')
- tray_state = fields.Selection(
- string='托盘状态',
- related='tray_id.state')
-
+ tray_ids = fields.One2many('sf.tray', 'workorder_id', string='托盘')
# def get_tray_info(self):
# @api.onchange('X_axis', 'Y_axis', 'Z_axis')
# def get_center_point(self):
# return 'X:%s,Y:%s,Z:%s' % (self.X_axis, self.Y_axis, self.Z_axis)
# 加工面
surface = fields.Selection([("前面", "前面"), ("后面", "后面"), ("左面", "左面"), ("右面", "右面"),
- ("上面", "上面")], required=True, default="顶面", string="加工面")
+ ("上面", "上面")], string="加工面1")
+
material_center_point = fields.Char(string='配料中心点')
X1_axis = fields.Float(string='Lx1', default=0)
Y1_axis = fields.Float(string='Ly1', default=0)
@@ -178,7 +171,8 @@ class MrpWorkOrder(models.Model):
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], string="检测结果")
- cnc_ids = fields.One2many("cnc.processing",'workorder_id', string="CNC加工")
+ cnc_ids = fields.One2many("cnc.processing", 'workorder_id', string="CNC加工")
+
# @api.depends('tray_id')
# def updateTrayState(self):
#
@@ -193,6 +187,11 @@ class MrpWorkOrder(models.Model):
# 'state': "占用",
# }
# )
+ def recreateManufacturing(self):
+ return ""
+
+ def recreateWorkerOrder(self):
+ return ""
'''
diff --git a/sf_route_workcenter/views/sf_tray_view.xml b/sf_route_workcenter/views/sf_tray_view.xml
index c9520f63..753b962c 100644
--- a/sf_route_workcenter/views/sf_tray_view.xml
+++ b/sf_route_workcenter/views/sf_tray_view.xml
@@ -14,7 +14,8 @@
attrs='{"invisible": [("production_id","=",False)]}'/>
-
+
diff --git a/sf_route_workcenter/views/sf_workorder.xml b/sf_route_workcenter/views/sf_workorder.xml
index daa77756..6d79a348 100644
--- a/sf_route_workcenter/views/sf_workorder.xml
+++ b/sf_route_workcenter/views/sf_workorder.xml
@@ -12,8 +12,10 @@
+
@@ -29,6 +31,8 @@
+ 左面:
+
@@ -45,72 +49,76 @@
-
+ 前面:
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+ 右面:
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+ 下面:
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+ 上面:
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -146,11 +154,27 @@
+
+
+
+
+
+
+
+
+
+
+
+