diff --git a/sf_base/commons/__init__.py b/sf_base/commons/__init__.py index d89945c1..e4193cf0 100644 --- a/sf_base/commons/__init__.py +++ b/sf_base/commons/__init__.py @@ -1 +1 @@ -from. import common +from . import common diff --git a/sf_base/commons/common.py b/sf_base/commons/common.py index a1aed3c2..05a2143f 100644 --- a/sf_base/commons/common.py +++ b/sf_base/commons/common.py @@ -8,7 +8,7 @@ class Common(models.Model): _name = 'sf.sync.common' _description = u'公用类' - def get_headers(self,token, secret_key): + def get_headers(self, token, secret_key): ''' 获取requests中的heardes参数 ''' @@ -19,5 +19,3 @@ class Common(models.Model): 'TIMESTAMP': str(timestamp), 'checkstr': check_sf_str} return headers - - diff --git a/sf_base/security/group_security.xml b/sf_base/security/group_security.xml index cfe816dd..b0d8bb6c 100644 --- a/sf_base/security/group_security.xml +++ b/sf_base/security/group_security.xml @@ -1,5 +1,43 @@ + + 制造普通用户 + + + + + + + + + + + + + + + 机床操作岗 + + + + + 刀具组装岗 + + + + + 工件装夹岗 + + + + + + 生产总监 + + + + + 计划 20 diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index 37daa2b3..1a550d41 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -40,3 +40,5 @@ access_maintenance_equipment_image,maintenance_equipment_image,model_maintenance + + diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index bf58c8f2..d4aa6ba4 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -12,7 +12,8 @@ class SfMaintenanceEquipmentCategory(models.Model): _inherit = 'maintenance.equipment.category' _description = '设备类别' - equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')], string='类型', default='机床') + equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')] + , string='类型', default='机床') class SfMaintenanceEquipment(models.Model): @@ -62,9 +63,10 @@ class SfMaintenanceEquipment(models.Model): else: record.equipment_maintenance_standards_ids = False - MTcode = fields.Char("编码", default=get_no) + MTcode = fields.Char("机台编码", default=get_no) created_user = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user) - equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')], compute='_compute_category_id') + equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')] + , compute='_compute_category_id') @api.depends('category_id') def _compute_category_id(self): @@ -72,8 +74,8 @@ class SfMaintenanceEquipment(models.Model): if record: record.equipment_type = record.category_id.equipment_type - code = fields.Char('机台号') - name = fields.Char('名称') + code = fields.Char('行业编码') + name = fields.Char('机台号') knife_type = fields.Selection( [("BT40", "BT40"), ("BT30", "BT30"), ("BT50", "BT50")], default="", string="刀把类型") @@ -152,6 +154,18 @@ class SfMaintenanceEquipment(models.Model): result.append((parameter.id, name)) return result + @api.model + def create(self, vals): + # 在创建设备之前执行一些自定义逻辑 + + equipment = super(SfMaintenanceEquipment, self).create(vals) + equipment.name = equipment.MTcode + '#' + equipment.category_id.name + + # 在创建设备之后执行一些自定义逻辑 + # ... + + return equipment + # @api.constrains('rotate_speed') # def _check_rotate_speed(self): # if self.rotate_speed <= 0: @@ -278,7 +292,8 @@ class SfMaintenanceEquipment(models.Model): detect_y_axis = fields.Char('检测Y轴') detect_z_axis = fields.Char('检测Z轴') detect_precision = fields.Char('测量精度') - detect_measurement_mode = fields.Selection([('光栅尺', '光栅尺'), ('容栅', '容栅'), ('磁栅', '磁栅'), ('激光干涉仪', '激光干涉仪')], string='测量方式') + detect_measurement_mode = fields.Selection([('光栅尺', '光栅尺'), ('容栅', '容栅'), ('磁栅', '磁栅'), + ('激光干涉仪', '激光干涉仪')], string='测量方式') detect_resolution = fields.Char('分辨率') detect_load_weight_max = fields.Char('最大负载重量') detect_weight = fields.Char('本体总重量') @@ -304,13 +319,15 @@ class SfMaintenanceEquipment(models.Model): robot_load_weight_max = fields.Char('最大负载重量') robot_weight = fields.Char('本体总重量') robot_repeatable_positioning_accuracy = fields.Char('重复定位精度') - robot_axis_num = fields.Selection([('2轴', '2轴'), ('3轴', '3轴'), ('4轴', '4轴'), ('5轴', '5轴'), ('6轴', '6轴'), ('7轴', '7轴'), ('8轴', '8轴')], string='轴数') + robot_axis_num = fields.Selection([('2轴', '2轴'), ('3轴', '3轴'), ('4轴', '4轴'), ('5轴', '5轴'), ('6轴', '6轴'), + ('7轴', '7轴'), ('8轴', '8轴')], string='轴数') axis_ids = fields.One2many('sf.robot.axis.num', 'equipment_id', string='动作范围') robot_track_dimensions_L = fields.Char('轨道尺寸(长)') robot_track_dimensions_W = fields.Char('轨道尺寸(宽)') robot_track_dimensions_H = fields.Char('轨道尺寸(高)') robot_drive_mode = fields.Char('驱动方式') - robot_installation_method = fields.Selection([('置地式', '置地式'), ('壁挂式', '壁挂式'), ('倒挂式', '倒挂式')], string='安装方式') + robot_installation_method = fields.Selection([('置地式', '置地式'), ('壁挂式', '壁挂式'), ('倒挂式', '倒挂式')], + string='安装方式') robot_operating_temperature = fields.Char('机器人环境温度') robot_operating_humidity = fields.Char('机器人环境湿度') @@ -433,7 +450,8 @@ class SfMaintenanceEquipment(models.Model): if next_maintenance_todo and last_maintenance_done: next_date = next_maintenance_todo.request_date date_gap = next_maintenance_todo.request_date - last_maintenance_done.close_date - # If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than 2 times the period and next request is in the future + # If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than + # 2 times the period and next request is in the future # We use 2 times the period to avoid creation too closed request from a manually one created if date_gap > timedelta(0) and date_gap > timedelta( days=equipment.period) * 2 and next_maintenance_todo.request_date > date_now: @@ -445,7 +463,8 @@ class SfMaintenanceEquipment(models.Model): elif next_maintenance_todo: next_date = next_maintenance_todo.request_date date_gap = next_maintenance_todo.request_date - date_now - # If next maintenance to do is in the future, and in more than 2 times the period, we insert an new request + # If next maintenance to do is in the future, and in more than 2 times the period, we insert + # an new request # We use 2 times the period to avoid creation too closed request from a manually one created if date_gap > timedelta(0) and date_gap > timedelta(days=equipment.period) * 2: next_date = date_now + timedelta(days=equipment.period) @@ -475,7 +494,8 @@ class SfMaintenanceEquipment(models.Model): if next_maintenance_todo and last_maintenance_done: next_date = next_maintenance_todo.request_date date_gap = next_maintenance_todo.request_date - last_maintenance_done.close_date - # If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than 2 times the period and next request is in the future + # If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than 2 + # times the period and next request is in the future # We use 2 times the period to avoid creation too closed request from a manually one created if date_gap > timedelta(0) and date_gap > timedelta( days=equipment.overhaul_period) * 2 and next_maintenance_todo.request_date > date_now: @@ -487,7 +507,8 @@ class SfMaintenanceEquipment(models.Model): elif next_maintenance_todo: next_date = next_maintenance_todo.request_date date_gap = next_maintenance_todo.request_date - date_now - # If next maintenance to do is in the future, and in more than 2 times the period, we insert an new request + # If next maintenance to do is in the future, and in more than 2 times the period, we insert + # an new request # We use 2 times the period to avoid creation too closed request from a manually one created if date_gap > timedelta(0) and date_gap > timedelta(days=equipment.overhaul_period) * 2: next_date = date_now + timedelta(days=equipment.overhaul_period) @@ -577,7 +598,8 @@ class SfMaintenanceEquipment(models.Model): if not next_requests: equipment._create_new_request1(equipment.overhaul_date) - image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id', string='加工能力', domain="[('type', '=', '加工能力')]") + image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id', string='加工能力', + domain="[('type', '=', '加工能力')]") class SfRobotAxisNum(models.Model): diff --git a/sf_maintenance/views/maintenance_views.xml b/sf_maintenance/views/maintenance_views.xml index 435e291c..ff0b6e73 100644 --- a/sf_maintenance/views/maintenance_views.xml +++ b/sf_maintenance/views/maintenance_views.xml @@ -52,11 +52,13 @@