diff --git a/sf_bf_connect/models/models.py b/sf_bf_connect/models/models.py index 9c9d59a1..3eeac229 100644 --- a/sf_bf_connect/models/models.py +++ b/sf_bf_connect/models/models.py @@ -25,5 +25,4 @@ class ResPartner(models.Model): return ran_str sf_token = fields.Char(u'Token', default=get_token) - sf_secret_key = fields.Char(u'密钥', default=get_secret) - + sf_secret_key = fields.Char(u'密钥', default=get_secret) \ No newline at end of file diff --git a/sf_dlm/data/product_data.xml b/sf_dlm/data/product_data.xml index aad3714c..f4b9b717 100644 --- a/sf_dlm/data/product_data.xml +++ b/sf_dlm/data/product_data.xml @@ -45,7 +45,6 @@ true serial - @@ -61,7 +60,6 @@ serial - 胚料采购模板 @@ -76,7 +74,6 @@ serial - \ No newline at end of file diff --git a/sf_dlm/data/tt.xml b/sf_dlm/data/tt.xml deleted file mode 100644 index 847e6a80..00000000 --- a/sf_dlm/data/tt.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - CNC加工产品模板 - - delivery - product - false - - - - False - - - - 胚料 - 胚料 - - - - 自加工 - - delivery - product - false - - - - False - - - - 外协 - - delivery - product - false - - - - False - - - - 采购 - - delivery - product - false - - - - False - - - \ No newline at end of file diff --git a/sf_dlm/models/__init__.py b/sf_dlm/models/__init__.py index 86d505b8..7d40ff65 100644 --- a/sf_dlm/models/__init__.py +++ b/sf_dlm/models/__init__.py @@ -1,3 +1,5 @@ from. import product_template +from. import product_supplierinfo + diff --git a/sf_dlm/models/product_supplierinfo.py b/sf_dlm/models/product_supplierinfo.py new file mode 100644 index 00000000..ae850401 --- /dev/null +++ b/sf_dlm/models/product_supplierinfo.py @@ -0,0 +1,11 @@ +from odoo import models, fields, api + + +class ResSupplierInfo(models.Model): + _inherit = 'product.supplierinfo' + + def _compute_is_subcontractor(self): + for supplier in self: + boms = supplier.product_id.variant_bom_ids + boms |= supplier.product_tmpl_id.bom_ids.filtered(lambda b: not b.product_id or b.product_id in (supplier.product_id or supplier.product_tmpl_id.product_variant_ids)) + supplier.is_subcontractor = supplier.partner_id in boms.subcontractor_id \ No newline at end of file diff --git a/sf_dlm/models/product_template.py b/sf_dlm/models/product_template.py index 40fcac15..725cbeb6 100644 --- a/sf_dlm/models/product_template.py +++ b/sf_dlm/models/product_template.py @@ -82,7 +82,7 @@ class ResProductTemplate(models.Model): item['model_height'] + model_type.embryo_tolerance), 'model_type_id': model_type.id, 'model_processing_panel': 'R', - 'model_machining_precision': item['model_machining_precision'], + 'model_machining_precision': item['model_machining_precision'], 'model_code': item['barcode'], 'length': item['model_long'], 'width': item['model_width'], @@ -92,7 +92,7 @@ class ResProductTemplate(models.Model): 'model_name': attachment.name, 'upload_model_file': [(6, 0, [attachment.id])], # 'single_manufacturing': True, - 'tracking': 'serial', + # 'tracking': 'serial', 'list_price': item['price'], # 'categ_id': self.env.ref('sf_dlm.product_category_finished_sf').id, 'materials_id': self.env['sf.production.materials'].search( @@ -158,14 +158,13 @@ class ResProductTemplate(models.Model): 'active': True } # 外协和采购生成的胚料需要根据材料型号绑定供应商 - if route_type == 'subcontract': - no_bom_copy_product_id.purchase_ok = True - no_bom_copy_product_id.seller_ids = [ - (0, 0, {'partner_id': supplier.partner_id.id, 'delay': 1.0, 'is_subcontractor': True})] - elif route_type == 'purchase': + if route_type == 'subcontract' or route_type == 'purchase': no_bom_copy_product_id.purchase_ok = True no_bom_copy_product_id.seller_ids = [ (0, 0, {'partner_id': supplier.partner_id.id, 'delay': 1.0})] + if route_type == 'subcontract': + partner = self.env['res.partner'].search([('id', '=', supplier.partner_id.id)]) + partner.is_subcontractor = True no_bom_copy_product_id.write(vals) logging.info('no_bom_copy_product_id-vals:%s' % vals) # product_id.product_tmpl_id.active = False @@ -249,7 +248,6 @@ class ResMrpBom(models.Model): [('materials_model_id', '=', materials_type.id)], limit=1, order='sequence asc') - logging.info('get_supplier-vals:%s' % seller_id) return seller_id # 匹配bom diff --git a/sf_dlm/views/product_template_view.xml b/sf_dlm/views/product_template_view.xml index c563f728..ab89ec5b 100644 --- a/sf_dlm/views/product_template_view.xml +++ b/sf_dlm/views/product_template_view.xml @@ -6,13 +6,13 @@ product.template - - - - + + + + - + @@ -36,18 +36,31 @@ - - - - - - - - - - - + + + diff --git a/sf_manufacturing/models/mrp_workcenter.py b/sf_manufacturing/models/mrp_workcenter.py index e853ab3f..f9f518c1 100644 --- a/sf_manufacturing/models/mrp_workcenter.py +++ b/sf_manufacturing/models/mrp_workcenter.py @@ -13,6 +13,24 @@ class ResWorkcenter(models.Model): 'maintenance.equipment', 'workcenter_id', string="Maintenance Equipment", check_company=True) + @api.onchange('machine_tool_id') + def update_machine_tool_is_binding(self): + machine_tool = self.env["sf.machine_tool"].search([('is_binding', '=', True)]) + if machine_tool: + for item in machine_tool: + workcenter_machine_tool = self.env["mrp.workcenter"].search([('machine_tool_id', '=', item.id)]) + if workcenter_machine_tool: + if self.machine_tool_id.id: + if workcenter_machine_tool.id != self.machine_tool_id.id: + self.machine_tool_id.is_binding = True + else: + self.machine_tool_id.is_binding = True + else: + self.machine_tool_id.is_binding = True + item.is_binding = False + else: + self.machine_tool_id.is_binding = True + def action_work_order(self): if not self.env.context.get('desktop_list_view', False): action = self.env["ir.actions.actions"]._for_xml_id("sf_manufacturing.mrp_workorder_action_tablet") diff --git a/sf_manufacturing/views/mrp_workcenter_views.xml b/sf_manufacturing/views/mrp_workcenter_views.xml index 186dce3c..9c040938 100644 --- a/sf_manufacturing/views/mrp_workcenter_views.xml +++ b/sf_manufacturing/views/mrp_workcenter_views.xml @@ -107,7 +107,7 @@ - + diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index dff52b17..5ef4b59d 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -12,7 +12,7 @@ - + diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index e37983e2..fa5ee076 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -27,7 +27,8 @@ class Sf_Mrs_Connect(http.Controller): # 查询状态为进行中且类型为获取CNC加工程序的工单 cnc_workorder = request.env['mrp.workorder'].with_user( request.env.ref("base.user_admin")).search([('production_id.name', '=', ret['production_order_no']), - ('routing_type', '=', '获取CNC加工程序')]) + ('routing_type', '=', '获取CNC加工程序'), + ('state', '=', 'progress')]) if cnc_workorder: # 拉取所有加工面的程序文件 # i = 1 diff --git a/sf_mrs_connect/models/sync_common.py b/sf_mrs_connect/models/sync_common.py index 7e2f6224..6e9c6510 100644 --- a/sf_mrs_connect/models/sync_common.py +++ b/sf_mrs_connect/models/sync_common.py @@ -111,7 +111,7 @@ class sfMaterialModel(models.Model): brand.active = item['active'], brand.mf_materia_post = item['mf_materia_post'], brand.materials_id = self.env['sf.production.materials'].search( - [("materials_no", '=', item['materials_id.materials_no'])]).id, + [("materials_no", '=', item['materials_id.materials_no'])]).id, brand.need_h = item['need_h'], brand.density = item['density'] else: @@ -158,9 +158,9 @@ class sfMaterialModel(models.Model): "need_h": item['need_h'], "mf_materia_post": item['mf_materia_post'], "density": item['density'], - # "tag_ids": item['tag_ids'] + # "tag_ids": item['tag_ids'] - }) + }) else: raise ValidationError("认证未通过") @@ -392,7 +392,7 @@ class MachineControlSystem(models.Model): brand.id = item['id'], brand.name = item['name'], brand.code = item['code'], - brand.brand_id=self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id, + brand.brand_id = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id, brand.active = item['active'] else: self.env['sf.machine.control_system'].create({ @@ -500,12 +500,9 @@ class MachineBrand(models.Model): "id": item['id'], "name": item['name'], "code": item['code'], - # "image_brand": item['image_brand'], - "active": item['active'], + "image_brand": '' if not item['image_brand'] else base64.b64encode(item.image_brand), "tag_ids": self.env['sf.machine.brand.tags'].search( - [("name", 'in', item['tag_ids'])]).ids - - + [("name", 'in', item['tag_ids'])]).ids }) else: raise ValidationError("认证未通过") @@ -517,8 +514,6 @@ class MachineTool(models.Model): url = '/api/machine_tool/list' crea_url = '/api/machine_tool/create' - - # 定时同步机床 def sync_machine_tool(self): sf_sync_config = self.env['res.config.settings'].get_values() @@ -657,7 +652,8 @@ class MachineToolType(models.Model): brand.number_of_knife_library = item['number_of_knife_library'], brand.rotate_speed = item['rotate_speed'], brand.number_of_axles = item['number_of_axles'], - brand.control_system_id = self.env['sf.machine.control_system'].search([('code', '=', item['control_system_id'])]).id, + brand.control_system_id = self.env['sf.machine.control_system'].search( + [('code', '=', item['control_system_id'])]).id, brand.x_axis = item['x_axis'], brand.y_axis = item['y_axis'], @@ -666,8 +662,9 @@ class MachineToolType(models.Model): brand.c_axis = item['c_axis'], brand.active = item['active'], brand.remark = item['remark'], - brand.brand_id=self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id, - brand.machine_tool_id = self.env['sf.machine_tool'].search([('code', '=', item['machine_tool_id'])]).id + brand.brand_id = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id, + brand.machine_tool_id = self.env['sf.machine_tool'].search( + [('code', '=', item['machine_tool_id'])]).id else: self.env['sf.machine_tool.type'].create({ @@ -677,7 +674,8 @@ class MachineToolType(models.Model): "number_of_knife_library": item['number_of_knife_library'], "rotate_speed": item['rotate_speed'], - 'machine_tool_id' : self.env['sf.machine_tool'].search([('code', '=', item['machine_tool_id'])]).id, + 'machine_tool_id': self.env['sf.machine_tool'].search( + [('code', '=', item['machine_tool_id'])]).id, "number_of_axles": item['number_of_axles'], "x_axis": item['x_axis'], "y_axis": item['y_axis'], @@ -686,7 +684,8 @@ class MachineToolType(models.Model): "c_axis": item['c_axis'], "remark": item['remark'], "precision": item['precision'], - 'control_system_id' : self.env['sf.machine.control_system'].search([('code', '=', item['control_system_id'])]).id, + 'control_system_id': self.env['sf.machine.control_system'].search( + [('code', '=', item['control_system_id'])]).id, "active": item['active'], 'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id, @@ -716,7 +715,8 @@ class MachineToolType(models.Model): "code": item['code'], "number_of_knife_library": item['number_of_knife_library'], "rotate_speed": item['rotate_speed'], - 'machine_tool_id' : self.env['sf.machine_tool'].search([('code', '=', item['machine_tool_id'])]).id, + 'machine_tool_id': self.env['sf.machine_tool'].search( + [('code', '=', item['machine_tool_id'])]).id, "number_of_axles": item['number_of_axles'], "x_axis": item['x_axis'], "y_axis": item['y_axis'], @@ -725,7 +725,8 @@ class MachineToolType(models.Model): "c_axis": item['c_axis'], "remark": item['remark'], "precision": item['precision'], - 'control_system_id' : self.env['sf.machine.control_system'].search([('code', '=', item['control_system_id'])]).id, + 'control_system_id': self.env['sf.machine.control_system'].search( + [('code', '=', item['control_system_id'])]).id, "active": item['active'], 'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id, @@ -836,7 +837,8 @@ class CuttingToolType(models.Model): brand.tool_length = item['tool_length'], brand.blade_number = item['blade_number'] brand.brand_id = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id, - brand.category_id = self.env['sf.cutting_tool.category'].search([('code', '=', item['category_id'])]).id + brand.category_id = self.env['sf.cutting_tool.category'].search( + [('code', '=', item['category_id'])]).id else: self.env['sf.cutting_tool.type'].create({ "id": item['id'], @@ -852,7 +854,8 @@ class CuttingToolType(models.Model): "tool_length": item['tool_length'], "blade_number": item['blade_number'], 'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id, - "category_id": self.env['sf.cutting_tool.category'].search([('code', '=', item['category_id'])]).id, + "category_id": self.env['sf.cutting_tool.category'].search( + [('code', '=', item['category_id'])]).id, }) else: raise ValidationError("认证未通过") @@ -887,13 +890,13 @@ class CuttingToolType(models.Model): "tool_length": item['tool_length'], "blade_number": item['blade_number'], 'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id, - "category_id": self.env['sf.cutting_tool.category'].search([('code', '=', item['category_id'])]).id, + "category_id": self.env['sf.cutting_tool.category'].search( + [('code', '=', item['category_id'])]).id, }) else: raise ValidationError("认证未通过") - class sfProcessingOrder(models.Model): _inherit = 'sf.processing.order' _description = '工序' @@ -948,4 +951,3 @@ class sfProcessingOrder(models.Model): }) else: raise ValidationError("认证未通过") -