diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py index 1c7219bc..7f3921a2 100644 --- a/sf_base/models/tool_base_new.py +++ b/sf_base/models/tool_base_new.py @@ -89,8 +89,8 @@ class CuttingToolModel(models.Model): '柄部类型', domain=[('type', '=', '柄部类型')]) cutting_direction_ids = fields.Many2many('maintenance.equipment.image', 'cutting_direction_library_rel', '走刀方向', domain=[('type', '=', '走刀方向')]) - suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', 'suitable_coolant_library_rel', - '适合冷却液', domain=[('type', '=', '冷却液')]) + suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', 'suitable_coolants_library_rel', + '适合冷却方式', domain=[('type', '=', '冷却方式')]) compaction_way_id = fields.Many2one('maintenance.equipment.image', '压紧方式', domain=[('type', '=', '压紧方式')]) integral_tool_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters', @@ -106,8 +106,10 @@ class CuttingToolModel(models.Model): chuck_basic_parameters_ids = fields.One2many('sf.tool.materials.basic.parameters', 'standard_library_id', string='夹头基本参数') cutting_speed_ids = fields.One2many('sf.cutting.speed', 'standard_library_id', string='切削速度Vc') - feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz') - feed_per_tooth_ids_3 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz') + feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz', + domain=[('cutting_speed', '!=', False)]) + feed_per_tooth_ids_3 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz', + domain=[('cutting_speed', '!=', False)]) material_model_id = fields.Many2one('sf.materials.model', '材料型号') # 适用夹头型号可以多选 @@ -241,3 +243,12 @@ class MaintenanceStandardImage(models.Model): else: record['image'] = "" return records + + +class ToolGroups(models.Model): + _name = 'sf.tool.groups' + _description = '刀具组' + + name = fields.Char('名称') + equipment_ids = fields.Many2many('maintenance.equipment', 'ref_maintenance_equipment', string='机台号') + remark = fields.Char('备注', size=50) diff --git a/sf_base/models/tool_base_new.py.rej b/sf_base/models/tool_base_new.py.rej new file mode 100644 index 00000000..6db1f28a --- /dev/null +++ b/sf_base/models/tool_base_new.py.rej @@ -0,0 +1,10 @@ +diff a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py (rejected hunks) +@@ -108,6 +108,4 @@ + cutting_speed_ids = fields.One2many('sf.cutting.speed', 'standard_library_id', string='切削速度Vc') +- feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz', +- domain=[('cutting_speed', '!=', False)]) +- feed_per_tooth_ids_3 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz', +- domain=[('cutting_speed', '!=', False)]) ++ feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz') ++ feed_per_tooth_ids_3 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz') + diff --git a/sf_base/models/tool_other_features.py b/sf_base/models/tool_other_features.py index 154bf275..ec3ad238 100644 --- a/sf_base/models/tool_other_features.py +++ b/sf_base/models/tool_other_features.py @@ -162,6 +162,7 @@ class FeedPerTooth(models.Model): _order = 'blade_diameter,cutting_width_depth_id,materials_type_id' name = fields.Char('名称') + cutting_speed = fields.Char('切削速度', required=True) product_template_id = fields.Many2one('product.template') standard_library_id = fields.Many2one('sf.cutting_tool.standard.library', string='标准库') blade_diameter = fields.Integer('刃部直径(mm)', readonly=True) diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index 77c3e810..1490b9ef 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -28,6 +28,7 @@ access_sf_sync_common,sf_sync_common,model_sf_sync_common,base.group_user,1,1,1, access_sf_international_standards,sf_international_standards,model_sf_international_standards,base.group_user,1,1,1,1 access_material_apply,material_apply,model_material_apply,base.group_user,1,1,1,1 access_sf_cutting_tool_standard_library,sf_cutting_tool_standard_library,model_sf_cutting_tool_standard_library,base.group_user,1,1,1,1 +access_sf_tool_groups,sf_tool_groups,model_sf_tool_groups,base.group_user,1,1,1,1 access_sf_tool_materials_basic_parameters,sf_tool_materials_basic_parameters,model_sf_tool_materials_basic_parameters,base.group_user,1,1,1,1 access_sf_cutting_speed,sf_cutting_speed,model_sf_cutting_speed,base.group_user,1,1,1,1 access_sf_feed_per_tooth,sf_feed_per_tooth,model_sf_feed_per_tooth,base.group_user,1,1,1,1 diff --git a/sf_base/views/tool_menu.xml b/sf_base/views/tool_menu.xml index cddb7d90..82ecca18 100644 --- a/sf_base/views/tool_menu.xml +++ b/sf_base/views/tool_menu.xml @@ -92,5 +92,12 @@ action="action_maintenance_equipment_image" sequence="5"/> + + diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml index f0e79d5f..29f14547 100644 --- a/sf_base/views/tool_views.xml +++ b/sf_base/views/tool_views.xml @@ -490,6 +490,28 @@ [] + + + 刀具组 + sf.tool.groups + + + + + + + + + + + + + 刀具组 + ir.actions.act_window + sf.tool.groups + tree,form,search + + diff --git a/sf_dlm_management/views/product_template_management_view.xml b/sf_dlm_management/views/product_template_management_view.xml index 94cb4b7f..b1d0f50f 100644 --- a/sf_dlm_management/views/product_template_management_view.xml +++ b/sf_dlm_management/views/product_template_management_view.xml @@ -39,7 +39,7 @@ - - - + diff --git a/sf_machine_connect/views/SfWorkOrderBarcodes.xml b/sf_machine_connect/views/SfWorkOrderBarcodes.xml index d1ba5126..5a24a0b7 100644 --- a/sf_machine_connect/views/SfWorkOrderBarcodes.xml +++ b/sf_machine_connect/views/SfWorkOrderBarcodes.xml @@ -13,7 +13,7 @@ - + diff --git a/sf_maintenance/security/ir.model.access.csv b/sf_maintenance/security/ir.model.access.csv index 877d9b76..ca18d942 100644 --- a/sf_maintenance/security/ir.model.access.csv +++ b/sf_maintenance/security/ir.model.access.csv @@ -1,10 +1,15 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_equipment_maintenance_standards,equipment_maintenance_standards,model_equipment_maintenance_standards,sf_group_equipment_user,1,1,1,1 -access_sf_maintenance_logs,sf_maintenance_logs,model_sf_maintenance_logs,sf_group_equipment_user,1,1,1,1 -access_maintenance_equipment,maintenance_equipment,model_maintenance_equipment,sf_group_equipment_user,1,1,1,1 -access_maintenance_standards,maintenance_standards,model_maintenance_standards,sf_group_equipment_user,1,1,1,1 -access_maintenance_standard_image,maintenance_standard_image,model_maintenance_standard_image,sf_group_equipment_user,1,1,1,1 -access_sf_robot_axis_num,sf_robot_axis_num,model_sf_robot_axis_num,sf_group_equipment_user,1,1,1,1 +access_equipment_maintenance_standards,equipment_maintenance_standards,model_equipment_maintenance_standards,sf_group_equipment_user,1,1,1,0 +access_sf_maintenance_logs,sf_maintenance_logs,model_sf_maintenance_logs,sf_group_equipment_user,1,0,0,0 +access_sf_maintenance_logs,sf_maintenance_logs,model_sf_maintenance_logs,sf_group_equipment_manager,1,1,1,0 +access_maintenance_equipment,maintenance_equipment,model_maintenance_equipment,sf_group_equipment_user,1,0,0,0 +access_maintenance_equipment,maintenance_equipment,model_maintenance_equipment,sf_group_equipment_manager,1,1,1,0 +access_maintenance_standards,maintenance_standards,model_maintenance_standards,sf_group_equipment_user,1,0,0,0 +access_maintenance_standards,maintenance_standards,model_maintenance_standards,sf_group_equipment_manager,1,1,1,0 +access_maintenance_standard_image,maintenance_standard_image,model_maintenance_standard_image,sf_group_equipment_user,1,0,0,0 +access_maintenance_standard_image,maintenance_standard_image,model_maintenance_standard_image,sf_group_equipment_manager,1,1,1,0 +access_sf_robot_axis_num,sf_robot_axis_num,model_sf_robot_axis_num,sf_group_equipment_user,1,0,0,0 +access_sf_robot_axis_num,sf_robot_axis_num,model_sf_robot_axis_num,sf_group_equipment_manager,1,1,1,0 access_maintenance_request_group_plan_dispatch,maintenance.request,maintenance.model_maintenance_request,sf_base.group_plan_dispatch,1,0,0,0 diff --git a/sf_maintenance/views/maintenance_views.xml b/sf_maintenance/views/maintenance_views.xml index 5266bced..0dc18355 100644 --- a/sf_maintenance/views/maintenance_views.xml +++ b/sf_maintenance/views/maintenance_views.xml @@ -48,7 +48,7 @@ - + diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index ed9375d7..185817e9 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -8,6 +8,8 @@ from odoo.exceptions import UserError from odoo.addons.sf_base.commons.common import Common from odoo.tools import float_compare, float_round, float_is_zero, format_datetime +from odoo.tools import float_compare, float_is_zero + class MrpProduction(models.Model): _inherit = 'mrp.production' @@ -259,9 +261,6 @@ class MrpProduction(models.Model): ) i += 1 for route in product_routing_workcenter: - if i == 1 and route.routing_type == '获取CNC加工程序': - workorders_values.append( - self.env['mrp.workorder'].json_workorder_str('', production, route)) if route.is_repeat is True: workorders_values.append( self.env['mrp.workorder'].json_workorder_str(k, production, route)) @@ -479,13 +478,100 @@ class MrpProduction(models.Model): for work in rec.workorder_ids: work.sequence = current_sequence current_sequence += 1 - if work.name == '获取CNC加工程序': - work.button_start() - #work.fetchCNC() - work.button_finish() + # if work.name == '获取CNC加工程序': + # work.button_start() + # #work.fetchCNC() + # work.button_finish() # 创建工单并进行排序 def _create_workorder(self): self._create_workorder3() self._reset_work_order_sequence() return True + + #修改标记已完成方法 + def button_mark_done1(self): + self._button_mark_done_sanity_checks() + + if not self.env.context.get('button_mark_done_production_ids'): + self = self.with_context(button_mark_done_production_ids=self.ids) + res = self._pre_button_mark_done() + if res is not True: + return res + + if self.env.context.get('mo_ids_to_backorder'): + productions_to_backorder = self.browse(self.env.context['mo_ids_to_backorder']) + productions_not_to_backorder = self - productions_to_backorder + else: + productions_not_to_backorder = self + productions_to_backorder = self.env['mrp.production'] + + + backorders = productions_to_backorder and productions_to_backorder._split_productions() + backorders = backorders - productions_to_backorder + + productions_not_to_backorder._post_inventory(cancel_backorder=True) + productions_to_backorder._post_inventory(cancel_backorder=True) + + # if completed products make other confirmed/partially_available moves available, assign them + done_move_finished_ids = (productions_to_backorder.move_finished_ids | productions_not_to_backorder.move_finished_ids).filtered(lambda m: m.state == 'done') + done_move_finished_ids._trigger_assign() + + # Moves without quantity done are not posted => set them as done instead of canceling. In + # case the user edits the MO later on and sets some consumed quantity on those, we do not + # want the move lines to be canceled. + (productions_not_to_backorder.move_raw_ids | productions_not_to_backorder.move_finished_ids).filtered(lambda x: x.state not in ('done', 'cancel')).write({ + 'state': 'done', + 'product_uom_qty': 0.0, + }) + + for production in self: + production.write({ + 'date_finished': fields.Datetime.now(), + 'product_qty': production.qty_produced, + 'priority': '0', + 'is_locked': True, + 'state': 'done', + }) + + for workorder in self.workorder_ids.filtered(lambda w: w.state not in ('done', 'cancel')): + workorder.duration_expected = workorder._get_duration_expected() + + if not backorders: + if self.env.context.get('from_workorder'): + return { + 'type': 'ir.actions.act_window', + 'res_model': 'mrp.production', + 'views': [[self.env.ref('mrp.mrp_production_form_view').id, 'form']], + 'res_id': self.id, + 'target': 'main', + } + if self.user_has_groups('mrp.group_mrp_reception_report') and self.picking_type_id.auto_show_reception_report: + lines = self.move_finished_ids.filtered(lambda m: m.product_id.type == 'product' and m.state != 'cancel' and m.quantity_done and not m.move_dest_ids) + if lines: + if any(mo.show_allocation for mo in self): + action = self.action_view_reception_report() + return action + return True + context = self.env.context.copy() + context = {k: v for k, v in context.items() if not k.startswith('default_')} + for k, v in context.items(): + if k.startswith('skip_'): + context[k] = False + action = { + 'res_model': 'mrp.production', + 'type': 'ir.actions.act_window', + 'context': dict(context, mo_ids_to_backorder=None, button_mark_done_production_ids=None) + } + if len(backorders) == 1: + action.update({ + 'view_mode': 'form', + 'res_id': backorders[0].id, + }) + else: + action.update({ + 'name': _("Backorder MO"), + 'domain': [('id', 'in', backorders.ids)], + 'view_mode': 'tree,form', + }) + return action \ No newline at end of file diff --git a/sf_manufacturing/models/mrp_routing_workcenter.py b/sf_manufacturing/models/mrp_routing_workcenter.py index 807dfbb5..c8e7d8aa 100644 --- a/sf_manufacturing/models/mrp_routing_workcenter.py +++ b/sf_manufacturing/models/mrp_routing_workcenter.py @@ -6,9 +6,9 @@ class ResMrpRoutingWorkcenter(models.Model): _inherit = 'mrp.routing.workcenter' routing_type = fields.Selection([ - ('获取CNC加工程序', '获取CNC加工程序'), - ('装夹', '装夹'), - ('前置三元定位检测', '前置三元定位检测'), + # ('获取CNC加工程序', '获取CNC加工程序'), + ('装夹预调', '装夹预调'), + # ('前置三元定位检测', '前置三元定位检测'), ('CNC加工', 'CNC加工'), ('后置三元质量检测', '后置三元质量检测'), ('解除装夹', '解除装夹'), diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 53307af7..7b54ebde 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -31,9 +31,9 @@ class ResMrpWorkOrder(models.Model): processing_panel = fields.Char('加工面') sequence = fields.Integer(string='工序') routing_type = fields.Selection([ - ('获取CNC加工程序', '获取CNC加工程序'), - ('装夹', '装夹'), - ('前置三元定位检测', '前置三元定位检测'), + # ('获取CNC加工程序', '获取CNC加工程序'), + ('装夹预调', '装夹预调'), + # ('前置三元定位检测', '前置三元定位检测'), ('CNC加工', 'CNC加工'), ('后置三元质量检测', '后置三元质量检测'), ('解除装夹', '解除装夹'), @@ -204,15 +204,15 @@ class ResMrpWorkOrder(models.Model): if route.routing_type == '切割': duration_expected = self.env['mrp.routing.workcenter'].sudo().search( [('name', '=', '切割')]).time_cycle - elif route.routing_type == '获取CNC加工程序': + # elif route.routing_type == '获取CNC加工程序': + # duration_expected = self.env['mrp.routing.workcenter'].sudo().search( + # [('name', '=', '获取CNC加工程序')]).time_cycle + elif route.routing_type == '装夹预调': duration_expected = self.env['mrp.routing.workcenter'].sudo().search( - [('name', '=', '获取CNC加工程序')]).time_cycle - elif route.routing_type == '工件装夹': - duration_expected = self.env['mrp.routing.workcenter'].sudo().search( - [('name', '=', '工件装夹')]).time_cycle - elif route.routing_type == '前置三元定位检测': - duration_expected = self.env['mrp.routing.workcenter'].sudo().search( - [('name', '=', '前置三元定位检测')]).time_cycle + [('name', '=', '装夹预调')]).time_cycle + # elif route.routing_type == '前置三元定位检测': + # duration_expected = self.env['mrp.routing.workcenter'].sudo().search( + # [('name', '=', '前置三元定位检测')]).time_cycle elif route.routing_type == 'CNC加工': duration_expected = self.env['mrp.routing.workcenter'].sudo().search( [('name', '=', 'CNC加工')]).time_cycle @@ -495,7 +495,7 @@ class ResMrpWorkOrder(models.Model): # 重写工单开始按钮方法 def button_start(self): - if self.routing_type == '装夹' and self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name: + if self.routing_type == '装夹预调' and self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name: self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name # 外协出库单,从“正在等待”变为“就绪”状态 if self.is_subcontract is True: @@ -581,7 +581,8 @@ class ResMrpWorkOrder(models.Model): if is_production_id == True and self.name == '解除装夹': for move_raw_id in self.production_id.move_raw_ids: move_raw_id.quantity_done = move_raw_id.product_uom_qty - self.production_id.state = 'done' + self.production_id.button_mark_done1() + # self.production_id.state = 'done' diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 23c659f5..ef635f78 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -62,7 +62,6 @@ class ResProductMo(models.Model): tool_thickness = fields.Float('厚度(mm)') tool_weight = fields.Float('重量(kg)') tool_hardness = fields.Integer('硬度(hrc)') - coating_material = fields.Char('涂层材质') # 整体式刀具特有字段 cutting_tool_total_length = fields.Float('总长度(mm)', digits=(6, 1)) @@ -97,8 +96,8 @@ class ResProductMo(models.Model): handle_type_id = fields.Many2one('maintenance.equipment.image', '柄部类型', domain=[('type', '=', '柄部类型')]) cutting_direction_ids = fields.Many2many('maintenance.equipment.image', 'rel_cutting_product_template', '走刀方向', domain=[('type', '=', '走刀方向')]) - suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', 'rel_coolant_product_template', - '适合冷却液', domain=[('type', '=', '冷却液')]) + suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', 'rel_coolants_product_template', + '适合冷却方式', domain=[('type', '=', '冷却方式')]) compaction_way_id = fields.Many2one('maintenance.equipment.image', '压紧方式', domain=[('type', '=', '压紧方式')]) @@ -202,7 +201,6 @@ class ResProductMo(models.Model): self.feed_per_tooth_ids = self.cutting_tool_model_id.feed_per_tooth_ids.filtered( lambda r: int(r.blade_diameter) == int(self.specification_id.blade_diameter)) elif self.cutting_tool_type == '夹头': - self.cutting_tool_clamping_tolerance = self.specification_id.clamping_tolerance self.cutting_tool_clamping_diameter_min = self.specification_id.min_clamping_diameter self.cutting_tool_clamping_diameter_min = self.specification_id.max_clamping_diameter self.cutting_tool_clamping_way = self.specification_id.clamping_mode @@ -213,7 +211,7 @@ class ResProductMo(models.Model): self.cutting_tool_jump_accuracy = self.specification_id.run_out_accuracy self.cutting_tool_max_load_capacity = self.specification_id.max_load_capacity self.cutting_tool_er_size_model = self.specification_id.er_size_model - self.cutting_tool_handle_ids = self.cutting_tool_model_id.handle_ids + self.cutting_tool_handle_id = self.cutting_tool_model_id.handle_id.id self.cooling_suit_type_ids = self.specification_id.cooling_jacket elif self.cutting_tool_type == '刀片': self.cutting_tool_total_length = self.specification_id.total_length @@ -262,7 +260,7 @@ class ResProductMo(models.Model): self.cutting_tool_top_angle = self.specification_id.top_angle self.cutting_tool_screw = self.specification_id.screw self.cutting_tool_wrench = self.specification_id.wrench - self.cutting_tool_blade_id = self.specification_id.blade_id + self.cutting_tool_blade_id = self.specification_id.blade_id.id self.cutting_tool_is_cooling_hole = self.specification_id.is_cooling_hole self.cutting_tool_locating_slot_code = self.specification_id.locating_slot_code self.cutting_tool_install_blade_tip_num = self.specification_id.install_blade_tip_num @@ -474,7 +472,6 @@ class ResProductMo(models.Model): cutting_tool_dynamic_balance_class = fields.Char('动平衡等级') cutting_tool_fit_nut_model = fields.Char('适用锁紧螺母型号') - # 夹头参数 cutting_tool_taper = fields.Integer('锥度(°)') cutting_tool_top_diameter = fields.Float('顶部直径') @@ -483,11 +480,17 @@ class ResProductMo(models.Model): cooling_suit_type_ids = fields.Char('适用冷却套型号') cutting_tool_max_load_capacity = fields.Float('最大负载能力(kg)') cutting_tool_er_size_model = fields.Char('尺寸型号') - cutting_tool_handle_ids = fields.Many2many( + # cutting_tool_handle_ids = fields.Many2many( + # 'sf.cutting_tool.standard.library', + # relation='product_cutting_tool_library_chuck_handle_rel', + # column1='model_id_1', + # column2='model_id_2', + # domain="[('cutting_tool_type', '=', '刀柄')]", + # string='适用刀柄型号' + # ) + + cutting_tool_handle_id = fields.Many2one( 'sf.cutting_tool.standard.library', - relation='product_cutting_tool_library_chuck_handle_rel', - column1='model_id_1', - column2='model_id_2', domain="[('cutting_tool_type', '=', '刀柄')]", string='适用刀柄型号' ) @@ -517,36 +520,6 @@ class ResProductMo(models.Model): if self.tool_thickness > 1000000: raise ValidationError("厚度不能超过1000000") - @api.constrains('fixture_clamp_workpiece_length_max') - def _check_fixture_clamp_workpiece_length_max_size(self): - if self.fixture_clamp_workpiece_length_max > 1000000: - raise ValidationError("夹持工件长度MAX不能超过1000000") - - @api.constrains('fixture_clamp_workpiece_width_max') - def _check_fixture_clamp_workpiece_width_max_size(self): - if self.fixture_clamp_workpiece_width_max > 1000000: - raise ValidationError("夹持工件宽度MAX不能超过1000000") - - @api.constrains('fixture_clamp_workpiece_height_max') - def _check_fixture_clamp_workpiece_height_max_size(self): - if self.fixture_clamp_workpiece_height_max > 1000000: - raise ValidationError("夹持工件高度MAX不能超过1000000") - - @api.constrains('fixture_maximum_clamping_force') - def _check_fixture_maximum_clamping_force_size(self): - if self.fixture_maximum_clamping_force > 100000000: - raise ValidationError("最大夹持力不能超过100000000") - - @api.constrains('fixture_through_hole_size') - def _check_fixture_through_hole_size_size(self): - if self.fixture_through_hole_size > 1000000: - raise ValidationError("过孔大小不能超过1000000") - - @api.constrains('fixture_screw_size') - def _check_fixture_through_hole_size_size(self): - if self.fixture_screw_size > 1000000: - raise ValidationError("螺牙大小不能超过1000000") - def _json_apply_machine_tool_type_item_code(self, item): code_arr = [] for i in item.product_id.fixture_apply_machine_tool_type_ids: @@ -565,12 +538,6 @@ class ResProductMo(models.Model): code_arr.append(i.code) return code_arr - def _json_handle_item_code(self, item): - code_arr = [] - for i in item.product_id.cutting_tool_handle_ids: - code_arr.append(i.code) - return code_arr - def _get_ids(self, param): type_ids = [] if not param: @@ -586,41 +553,6 @@ class ResProductMo(models.Model): self.detailed_type = 'product' self.sale_ok = False - @api.onchange('fixture_material_id') - def _onchange_fixture_material_id(self): - for item in self: - if item.fixture_material_id.id != item.fixture_model_id.fixture_material_id.id: - item.fixture_model_id = False - - @api.onchange('fixture_model_id') - def _onchange_fixture_model_id(self): - for item in self: - if self.fixture_material_type in ['气动夹具', '转接板(锁板)夹具', '磁吸夹具', '虎钳夹具', '零点卡盘']: - item.brand_id = item.fixture_model_id.brand_id.id - item.fixture_model_file = item.fixture_model_id.model_file - item.tool_length = item.fixture_model_id.length - item.tool_width = item.fixture_model_id.width - item.tool_height = item.fixture_model_id.height - item.tool_weight = item.fixture_model_id.weight - item.materials_type_id = item.fixture_model_id.materials_model_id.id - item.fixture_maximum_carrying_weight = item.fixture_model_id.maximum_carrying_weight - item.fixture_maximum_clamping_force = item.fixture_model_id.maximum_clamping_force - if self.fixture_material_type in ['零点卡盘', '转接板(锁板)夹具']: - item.fixture_clamping_way = item.fixture_model_id.clamping_way - item.fixture_port_type = item.fixture_model_id.port_type - if self.fixture_material_type in ['气动夹具', '转接板(锁板)夹具', '磁吸夹具']: - item.fixture_driving_way = item.fixture_model_id.driving_way - if self.fixture_material_type in ['气动夹具', '磁吸夹具', '虎钳夹具', '零点卡盘']: - item.fixture_through_hole_size = item.fixture_model_id.through_hole_size - item.fixture_screw_size = item.fixture_model_id.screw_size - if self.fixture_material_type in ['气动夹具', '转接板(锁板)夹具', '磁吸夹具', '虎钳夹具']: - item.fixture_clamp_workpiece_length_max = item.fixture_model_id.clamp_workpiece_length_max - item.fixture_clamp_workpiece_width_max = item.fixture_model_id.clamp_workpiece_width_max - item.fixture_clamp_workpiece_height_max = item.fixture_model_id.clamp_workpiece_height_max - item.fixture_clamp_workpiece_diameter_max = item.fixture_model_id.clamp_workpiece_diameter_max - item.fixture_apply_machine_tool_type_ids = self._get_ids( - item.fixture_model_id.apply_machine_tool_type_ids) - def _get_volume_uom_id_from_ir_config_parameter(self): product_length_in_feet_param = self.env['ir.config_parameter'].sudo().get_param('product.volume_in_cubic_feet') if product_length_in_feet_param == '1': @@ -804,15 +736,12 @@ class ResProductFixture(models.Model): fixture_model_id = fields.Many2one('sf.fixture.model', '夹具型号') specification_fixture_id = fields.Many2one('sf.fixture.materials.basic.parameters', '夹具规格') - fixture_material_id = fields.Many2one('sf.fixture.material', string="夹具物料", required=True) + fixture_material_id = fields.Many2one('sf.fixture.material', string="夹具物料") fixture_material_type = fields.Char(string="夹具物料类型", related='fixture_material_id.name') - multi_mounting_type_id = fields.Many2one('sf.multi_mounting.type', string="联装类型", required=True) + multi_mounting_type_id = fields.Many2one('sf.multi_mounting.type', string="联装类型") model_file = fields.Binary(string="3D模型图") # 夹具物料基本参数 - # length = fields.Float('长度(mm)', digits=(16, 2)) - # width = fields.Float('宽度(mm)', digits=(16, 2)) - # height = fields.Float('高度(mm)', digits=(16, 2)) diameter = fields.Float('直径(mm)', digits=(16, 2)) # '零点卡盘' 字段 diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv index 05064e79..7632686f 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -6,10 +6,10 @@ access_sf_model_type_manager,sf_model_type,model_sf_model_type,sf_base.group_sf_ access_sf_product_model_type_routing_sort,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0 access_sf_product_model_type_routing_sort_manager,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,0 access_sf_embryo_model_type_routing_sort,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0 -access_sf_embryo_model_type_routing_sort_manager,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,1 +access_sf_embryo_model_type_routing_sort_manager,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,0 access_sf_surface_technics_model_type_routing_sort,sf_surface_technics_model_type_routing_sort,model_sf_surface_technics_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0 access_sf_surface_technics_model_type_routing_sort_manager,sf_surface_technics_model_type_routing_sort,model_sf_surface_technics_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,0 -access_sf_production_line,sf.production.line,model_sf_production_line,sf_base.group_sf_mrp_user,1,0,0,0 +access_sf_production_line,sf.production.line,model_sf_production_line,sf_base.group_sf_mrp_user,1,1,1,0 access_sf_production_line_manager,sf.production.line,model_sf_production_line,sf_base.group_sf_mrp_manager,1,1,1,0 access_maintenance_equipment_tool,maintenance_equipment_tool,model_maintenance_equipment_tool,sf_base.group_sf_mrp_user,1,0,0,0 access_maintenance_equipment_tool_manager,maintenance_equipment_tool,model_maintenance_equipment_tool,sf_base.group_sf_mrp_manager,1,1,1,0 @@ -42,7 +42,7 @@ access_mrp_production_stock_worker,mrp.production stock_worker,mrp.model_mrp_pro access_product_product_user,product.product user,product.model_product_product,sf_base.group_sf_mrp_user,1,0,0,0 access_product_template_user,product.template user,product.model_product_template,sf_base.group_sf_mrp_user,1,0,0,0 access_uom_uom_user,uom.uom user,uom.model_uom_uom,sf_base.group_sf_mrp_user,1,0,0,0 -access_product_supplierinfo_user,product.supplierinfo user,product.model_product_supplierinfo,sf_base.group_sf_mrp_user,1,1,1,0 +access_product_supplierinfo_user,product.supplierinfo user,product.model_product_supplierinfo,sf_base.group_sf_mrp_user,1,0,0,0 access_res_partner,res.partner,base.model_res_partner,sf_base.group_sf_mrp_user,1,0,0,0 access_mrp_workorder_mrp_user,mrp.workorder.user,mrp.model_mrp_workorder,sf_base.group_sf_mrp_user,1,1,1,0 access_mrp_workorder_mrp_manager,mrp.workorder,mrp.model_mrp_workorder,sf_base.group_sf_mrp_user,1,1,1,0 @@ -91,6 +91,7 @@ access_mrp_production,mrp_production,model_mrp_production,sf_base.group_plan_dis access_mrp_workorder,mrp_workorder,model_mrp_workorder,sf_base.group_plan_dispatch,1,1,1,0 access_sf_production_line_group_plan_dispatch,sf.production.line,model_sf_production_line,sf_base.group_plan_dispatch,1,0,0,0 access_sf_production_line_group_plan_director,sf.production.line,model_sf_production_line,sf_base.group_plan_director,1,1,1,0 +access_sf_production_line,sf.production.line,model_sf_production_line,sf_maintenance.sf_group_equipment_user,1,1,1,0 access_mrp_workcenter,mrp_workcenter,model_mrp_workcenter,sf_base.group_plan_dispatch,1,1,1,0 access_mrp_bom,mrp.bom,mrp.model_mrp_bom,sf_base.group_plan_dispatch,1,1,1,0 access_mrp_bom_line,mrp.bom.line,mrp.model_mrp_bom_line,sf_base.group_plan_dispatch,1,0,0,0 diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 53373c51..8a9214e9 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -162,11 +162,11 @@ + attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/> + attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/> + attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
@@ -219,7 +219,7 @@ - + @@ -241,10 +241,7 @@ placeholder="如有预调程序信息请在此处输入....."/> - - - - +
左面:
@@ -397,8 +394,10 @@ + + diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index c32bde08..29a9be13 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -81,6 +81,25 @@ class ReSaleOrder(models.Model): } return self.env['sale.order.line'].create(vals) + @api.constrains('order_line') + def check_order_line(self): + for item in self: + if not item.order_line: + raise UserError('请选择【订单行】中的【产品】') + for line in item.order_line: + if not line.product_template_id: + raise UserError('请对【订单行】中的【产品】进行选择') + if not line.name: + raise UserError('请对【订单行】中的【说明】进行输入') + if line.product_qty == 0: + raise UserError('请对【订单行】中的【数量】进行输入') + if not line.product_uom: + raise UserError('请对【订单行】中的【计量单位】进行选择') + if line.price_unit == 0: + raise UserError('请对【订单行】中的【单价】进行输入') + if not line.tax_id: + raise UserError('请对【订单行】中的【税】进行选择') + class ResaleOrderLine(models.Model): _inherit = 'sale.order.line' @@ -95,6 +114,28 @@ class RePurchaseOrder(models.Model): check_status = fields.Selection([('pending', '待审核'), ('approved', '已审核'), ('fail', '不通过')], '审核状态') remark = fields.Text('备注') + def button_confirming(self): + self.write({'state': 'purchase', 'check_status': 'pending'}) + + @api.constrains('order_line') + def check_order_line(self): + for item in self: + if not item.order_line: + raise UserError('该询价单未添加【产品】,请进行添加') + for line in item.order_line: + if not line.product_id: + raise UserError('【产品】未添加,请进行添加') + if not line.name: + raise UserError('请对【产品】中的【说明】进行输入') + if line.product_qty == 0: + raise UserError('请对【产品】中的【数量】进行输入') + if not line.product_uom: + raise UserError('请对【产品】中的【计量单位】进行选择') + if line.price_unit == 0: + raise UserError('请对【产品】中的【单价】进行输入') + if not line.taxes_id: + raise UserError('请对【产品】中的【税】进行选择') + def write(self, vals): if self.env.user.has_group('sf_base.group_purchase_director'): if vals.get('check_status'): @@ -103,9 +144,19 @@ class RePurchaseOrder(models.Model): return super().write(vals) def button_confirm(self): - self.check_status = 'pending' - res = super().button_confirm() - return res + for order in self: + if order.state not in ['draft', 'sent', 'purchase']: + continue + order.order_line._validate_analytic_distribution() + order._add_supplier_to_product() + # Deal with double validation process + if order._approval_allowed(): + order.button_approve() + else: + order.write({'state': 'to approve'}) + if order.partner_id not in order.message_partner_ids: + order.message_subscribe([order.partner_id.id]) + return True class ResPartnerToSale(models.Model): diff --git a/sf_sale/security/ir.model.access.csv b/sf_sale/security/ir.model.access.csv index 569c146f..3f9eee1f 100644 --- a/sf_sale/security/ir.model.access.csv +++ b/sf_sale/security/ir.model.access.csv @@ -49,6 +49,8 @@ access_uom_category_group_purchase,uom_category_group_purchase,uom.model_uom_cat access_uom_category_group_purchase_director,uom_category_group_purchase_director,uom.model_uom_category,sf_base.group_purchase_director,1,0,0,0 access_sale_order_check_wizard_group_sale_salemanager,sale_order_check_wizard_group_sale_salemanager,model_sale_order_check_wizard,sf_base.group_sale_salemanager,1,1,1,0 access_sale_order_check_wizard_group_sale_director,sale_order_check_wizard_group_sale_director,model_sale_order_check_wizard,sf_base.group_sale_director,1,1,1,0 +access_account_move_line_group_sale_salemanager,account_move_line_group_sale_salemanager,account.model_account_move_line,sf_base.group_sale_salemanager,1,1,1,0 +access_account_move_line_group_sale_director,account_move_line_group_sale_director,account.model_account_move_line,sf_base.group_sale_director,1,1,1,0 access_account_move_line_group_purchase,account_move_line_group_purchase,account.model_account_move_line,sf_base.group_purchase,1,1,1,0 access_account_move_line_group_purchase_director,account_move_line_group_purchase_director,account.model_account_move_line,sf_base.group_purchase_director,1,1,1,0 access_res_users_group_purchase,res_user_group_purchase,model_res_users,sf_base.group_purchase,1,1,1,0 @@ -71,9 +73,13 @@ access_crm_tag_group_sale_salemanager,crm_tag_group_sale_salemanager,sales_team. access_crm_tag_group_sale_director,crm_tag_group_sale_director,sales_team.model_crm_tag,sf_base.group_sale_director,1,1,1,0 access_sale_order,sale.order,sale.model_sale_order,sf_base.group_plan_dispatch,1,0,0,0 -access_res_partner_group_purchase,res_partner_group_purchase,base.model_res_partner,sf_base.group_purchase,1,1,1,0 -access_res_partner_group_purchase_director,res_partner_group_purchase_director,base.model_res_partner,sf_base.group_purchase_director,1,1,1,0 +access_res_partner_group_sale_salemanager,res_partner_group_sale_salemanager,base.model_res_partner,sf_base.group_sale_salemanager,1,0,1,0 +access_res_partner_group_sale_director,res_partner_group_sale_director,base.model_res_partner,sf_base.group_sale_director,1,0,1,0 +access_res_partner_group_purchase,res_partner_group_purchase,base.model_res_partner,sf_base.group_purchase,1,0,1,0 +access_res_partner_group_purchase_director,res_partner_group_purchase_director,base.model_res_partner,sf_base.group_purchase_director,1,0,1,0 access_sale_advance_payment_inv_group_sale_salemanager,sale_advance_payment_inv_group_sale_salemanager,sale.model_sale_advance_payment_inv,sf_base.group_sale_salemanager,1,1,1,0 access_sale_advance_payment_inv_group_sale_director,sale_advance_payment_inv_group_sale_director,sale.model_sale_advance_payment_inv,sf_base.group_sale_director,1,1,1,0 +access_sale_report_group_sale_salemanager,sale_report_group_sale_salemanager,sale.model_sale_report,sf_base.group_sale_salemanager,1,0,1,0 +access_sale_report_group_sale_director,sale_report_group_sale_director,sale.model_sale_report,sf_base.group_sale_director,1,0,1,0 diff --git a/sf_sale/views/purchase_order_view.xml b/sf_sale/views/purchase_order_view.xml index 51dfaf63..b22bb584 100644 --- a/sf_sale/views/purchase_order_view.xml +++ b/sf_sale/views/purchase_order_view.xml @@ -11,20 +11,25 @@ - +
+ + + @@ -310,7 +314,7 @@

- +

@@ -318,6 +322,8 @@ + + + @@ -513,6 +521,8 @@ name="%(sf_tool_management.sf_tool_change_requirement_information_act)d" type="action" context="{ 'default_name':name, + 'default_code':code, + 'default_tool_groups_id':tool_groups_id, 'default_production_line_id': production_line_id, 'default_maintenance_equipment_id': maintenance_equipment_id, 'default_machine_table_type_id': machine_table_type_id, @@ -548,6 +558,8 @@ name="%(sf_tool_management.sf_tool_transfer_request_information_act)d" type="action" context="{ 'default_name':name, + 'default_code':code, + 'default_tool_groups_id':tool_groups_id, 'default_production_line_id': production_line_id, 'default_maintenance_equipment_id': maintenance_equipment_id, 'default_machine_table_type_id': machine_table_type_id, @@ -587,6 +599,8 @@ name="%(sf_tool_management.sf_tool_change_requirement_information_act)d" type="action" context="{ 'default_name':name, + 'default_code':code, + 'default_tool_groups_id':tool_groups_id, 'default_production_line_id': production_line_id, 'default_maintenance_equipment_id': maintenance_equipment_id, 'default_machine_table_type_id': machine_table_type_id, @@ -673,9 +687,11 @@ + + @@ -856,7 +872,9 @@ + + @@ -878,7 +896,7 @@ - +