PPwun=>U0BE1cTJewCDU48|2CBA#CD{){VTiV0c%0_Gn% z2-~&RCrCV|la=K~H!LjRqStWx!u&bu!1QZ#DG8BOjHK5-kwa9Skd2%tWhE>cp?Px( zf#q=i^@0^ZNzLZV72MBVYi@MZOP|V9oG~FX$$AVuF^*1s%WtO_r^|XheF)F;lLD-x z!V)u%!jHkW6_6-ID3H|1M=}MGVqxW0_!o-qj3dfxfLX=~Di7&b(m@X@LQ3NNd`%q9 zYmUof3W7bh5+kqFK9})eto0Sn`9|E7 lQ(UIjZwBUEl! z^7`=xm8}4VA?t{+y1dhgy*$OUAFkzG%jYl%8G9+dX3?IIyErf21ti7(nOa>nU}aNH z@RW;3WQfjCegCZ31l<6A>Yd&1c#%dHqSEIUsioZB*ee?V4 Rg9 z9t&FijEIK5l8gjZl*dif=}emrwsYm*t8#^{bw}L)* unybitpq^aFr z=kd!djqyvn3TI;F;O0{RfJD)vlz|7qOOyE3fZ)Q?40%bJ)-nSF#i>@;8Q<^B#T+Z| zxT>dKDMGP7&lpLi_cIXPCnxxTM*4d>J>6hpDimr6=?Liqu02j%;?vgA71|g jwbaQ`YuhXl6`I&yZZ8OJDMv~4hpYfk>g~%72&aQ6? zZl(B!uOG0rR+^wrdd|`6ql=?qR847M-&d#&ezw1a>n9g>K}d5X+o?8{V^f&P=^bQo zKCuXv&|YqC*AW_!Ek^n+5~Li{vX6C7H2e~?qGEuBXr>Oh@Wq9W0GxJ@g+RsJvK4E) zN)s{#wl5=QWv@f;DxoKescRZ%Y)s6H%H6rQuqTvY=UY|SMy% QlBg!$ zxa=aRcM7@rW-ArFuuqg!CRlCuf!`__G^h9ic`$$!BSFsi=!fpOrC%O@)MLt^C3KS| zrRADJT|>21s(GL6%2MtiFvr1E%=$C&c#UF-$DdY&JhH4M_zWep`M??vZGr?vp9^_# zX0Qgt7buLLcbE~Ccb}l4{Bkjush9$gMh8>U%Lf?o+E=#(fzigPSG0`VE{YyT`JM>I z^7t^Y$=L)_W*vk4-6E`F(7am?oSS%hcMpvAjlo5ZB!yr=Bb(}V4lOI#q&UQJBBlm@ z^n6&w*bLRcLW;HSVB%3=5}N;O_|Wmyt!qMbE76uCk(``jJ*M$1f)-d!D(ppA vN3bQ3e- z(-%qAz7)+#&ww%B)ilwNG3mmqUx3|?BE04OzWvZAiBq6-!h&J{OcVvv^^FLAYhE?L z;v>C9m(bnc<>(wMG+1{lRZ>#8QWq8Shxu{7{P&z?GVOFxd=F&tfvVY?__zOaoV9t< zs>-CpY=3Am)HX+RptCDql2T?Qm|16g45Oau_GBVT((FU2ny=GB?H^Zn7v4)Z*>ZYa zW}KwU*<*OXSe7;keGEo~43k@Slc@Bwrd43*BJy!A6n<+#lp*&uq3pAT5KA=O)gf#q zqW=lb@bAFSrnMPz?aSpZuwa?_6`{pk_GXbC;l~j-Hy^!usK~B^GTF?1qjrOEQFL6v zVh*(LZzxZb%syj$T=%l0IQF+`k|cwlt%dS)Z EwG7|+Jfexk#w;eTC xRC21 ZM{}cxG>I)?;ZZDZ>!6Tn zyvRzVSF2qRp7_gx2tdmbUE?`ydd-FSnY9Nt(@fCCo)VaM{!>K@;nRvD5p|7)?qLKT zaQ*G0w88!81jL(Ru!ebRC|h;uw#h}|1Fdkutv;{ 8hd|$54+l%to{NQh<0WEcPEoa}BrQ zHVmrNK|T2_dA?U3`oDye8{hW~?c7EMdhA0^M9-H6vJhpQV3PchC7RFZhJKBCJDT_X zcQ29aLT2y11^k~Z;u StS@CNluW1krHJhE;*XZDkanN%Nd gve z*(A|naOEr?Z_7gIZ2NXgQp8bRZEcG(zo=4v&ho&v-JkO|r+w_}z{q5SN^`;h9hq1# zYWgsRIXC8ew&$Z0lRL`oddZ95+5@YyrPdRss^p1a6Mamgx|7T1BkCcfmXS1T%zVKD zs`=3+?F3ww)7E*@S)3IDwOT~hXAL?`y5!!lS0HhlF{AR&iGoK6ZjfK&=5#{C>#Z}> zmM-uEjQ6ss@;a0K3k1apnc%TW5(N2)f2CLV=H=C#^_Sl(?}u13|0hf(V_o;LhwNmc z;~#Y0y$XdhTv750^{evCez#JVrl>_0qOi(D-!29_h&P~U^0OZjaY1(3|CaTFs&-Dm zL~LWqf6Y7-vNm#P!#JVIFQI}yFA%03MQk(2X|AHp5yc;78azD=(#p*}oIS306l`fO zn|{<#l1d+qdUK;~^WOrl mu=yD@G0+)B|M^7jg#6|D)n`>3vzOLBL4 z;S8w2$uD5lGeF4Tne4T;6t@*QWTFs*c13)@-p3Uytc)RmrsZQq{Gjx=PsVd4hflZy zrhnSP)xx9K5rU;9u0{~M0SU?W5-M;$1JQcYbc8S!=xCqM7SsHxt;h=}e6yOiy_k^# z@3+`;+K5HmvLm2Q!1-yqh(ZrHj-i!O?s=H_@zoM;iCh6K{8HusTr^Wl^EWS&JqLIkvhjF{JfU~_oda4GqCu!peU)LSP{fIv jdiYaniEL~=B@Sny7H&cZq13{ zIP@Z;z4p0PscQ NGWb0%v1eG%Ed JXzDW3rT3!Q?^R70HZ*K=X z-S2%WR~}5n%0%0ud4U)SIHqmh<#r!9PUZ~Yf#VvzQ&-#?nKn-DiSjpOOp- T5H*QuYMa(|)e<5cBrp?7FDqWelVENdGwUx4sZCe**AV4i~@ z>Q&O{|HwU_A%x&!>!Gh`^=(^87|@78Qv#lCEkfe6rqFl6Ze#joILSR6vYvuIvgNaA zUePG0zt5&J5F&R-eENiostxJ@nX%}+e6h8=MWFWjl{EkhxzsT&byS|t4Ss;`I#wGG z88s@SF7afgSfJE(UI7>zFA&jE+Gw)b0bQ&E6L;&KC#yJQ7(pl5`$dRy&SP_Em2{}$ zi|cwyXtIWorkrry@WdCeggs%PX%Y9EBdPK016g<{bt$| 3Z?zG##HAFTG5ikC{H6&59P68w0Gt5afCs-j!c8Ad{_CG%c z9WTc)Gs;~*gtXr!m2AmwRRg6uEw*RKTsIIGokBecoA*7-?$6IZX5{T=HQZSxKgn0D z+l%xw3TM7I%m2yWuD1aiPV|GX;|sd3j`~n`F@EGVqW9L{OG?2>oyXs*`s`jcJPXhB z3p;&NO8Inwm2|$=LLis$x-oCbRjmF}Qxwya`)D*`03F3c \ No newline at end of file diff --git a/mrp_maintenance/static/src/components/menuPopup.xml b/mrp_maintenance/static/src/components/menuPopup.xml new file mode 100644 index 00000000..b6a8ea8b --- /dev/null +++ b/mrp_maintenance/static/src/components/menuPopup.xml @@ -0,0 +1,8 @@ + + + diff --git a/mrp_maintenance/tests/__init__.py b/mrp_maintenance/tests/__init__.py new file mode 100644 index 00000000..461aff90 --- /dev/null +++ b/mrp_maintenance/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import test_mrp_maintenance diff --git a/mrp_maintenance/tests/test_mrp_maintenance.py b/mrp_maintenance/tests/test_mrp_maintenance.py new file mode 100644 index 00000000..9b2b9ada --- /dev/null +++ b/mrp_maintenance/tests/test_mrp_maintenance.py @@ -0,0 +1,263 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import time +from datetime import datetime, timedelta +from odoo.tests import common, Form + + +class TestMrpMaintenance(common.TransactionCase): + + @classmethod + def setUpClass(cls): + super().setUpClass() + + # Relative models + cls.ResUsers = cls.env['res.users'] + cls.equipment = cls.env['maintenance.equipment'] + + # User references + cls.main_company = cls.env.ref('base.main_company') + cls.technician_user_id = cls.env.ref('base.user_root') + cls.maintenance_team_id = cls.env.ref('maintenance.equipment_team_maintenance') + cls.stage_repaired_id = cls.env.ref('maintenance.stage_3').id + cls.stage_id = cls.env.ref('maintenance.stage_0').id + cls.category_id = cls.env['maintenance.equipment.category'].create({ + 'name': 'Monitors - Test', + 'technician_user_id': cls.env.ref('base.user_admin').id, + 'color': 3, + }) + + # Create user + cls.user = cls.ResUsers.create({ + 'name': "employee", + 'company_id': cls.main_company.id, + 'login': "employee", + 'email': "employee@yourcompany.example.com", + 'groups_id': [(6, 0, [cls.env.ref('base.group_user').id])] + }) + + # Create user with extra rights + cls.manager = cls.ResUsers.create({ + 'name': "Equipment Manager", + 'company_id': cls.main_company.id, + 'login': "manager", + 'email': "eqmanager@yourcompany.example.com", + 'groups_id': [(6, 0, [cls.env.ref('maintenance.group_equipment_manager').id])] + }) + + # Create method for create a maintenance request + def _create_request(self, name, request_date, equipment_id, maintenance_type): + values = { + 'name': name, + 'request_date': request_date, + 'user_id': self.user.id, + 'owner_user_id': self.user.id, + 'equipment_id': equipment_id.id, + 'maintenance_type': maintenance_type, + 'stage_id': self.stage_id, + 'maintenance_team_id': self.maintenance_team_id.id, + } + return self.env['maintenance.request'].create(values) + + def test_00_mrp_maintenance(self): + + """ In order to check Next preventive maintenance date""" + """ + ex: equipment = Acer Laptop + effective_date = 25-04-2018 + period = 5 + + preventive maintenance date = effective date + period + 30-04-2018 = 25-04-2018 + 5 days + + create maintenance request + request_date = effective date + period + 30-04-2018 = 25-04-2018 + 5 days + + close maintenance request and calculate preventive maintenance date + close_date = 05-05-2018 + + preventive maintenance date = close_date + period + 10-05-2018 = 05-05-2018 + 5day + """ + + # Required for `assign_date` to be visible in the view + with self.debug_mode(): + # Create a new equipment + equipment_form = Form(self.equipment) + equipment_form.name = 'Acer Laptop' + equipment_form.maintenance_team_id = self.maintenance_team_id + equipment_form.category_id = self.category_id + equipment_form.technician_user_id = self.technician_user_id + equipment_form.assign_date = time.strftime('%Y-%m-%d') + equipment_form.serial_no = 'MT/127/18291015' + equipment_form.expected_mtbf = 2 + equipment_form.effective_date = (datetime.now().date() + timedelta(days=5)).strftime("%Y-%m-%d") + equipment_form.period = 5 + equipment_01 = equipment_form.save() + + # Check that equipment is created or not + self.assertTrue(equipment_01, 'Equipment not created') + + # Check next preventive maintenance date = effective date + period + self.assertEqual(equipment_01.next_action_date, datetime.now().date() + timedelta(days=10), 'Wrong next preventive maintenance date.') + + # Create a maintenance request + maintenance_request_01 = self._create_request(name='Display not working', request_date=datetime.now().date() + timedelta(days=10), equipment_id=equipment_01, maintenance_type="preventive") + + # check that maintenance_request is created or not + self.assertTrue(maintenance_request_01, 'Maintenance Request not created') + + # Check next preventive maintenance date when there is only one maintenance request created + self.assertEqual(equipment_01.next_action_date, datetime.now().date() + timedelta(days=10), 'Wrong next preventive maintenance calculated when there is maintenance todo') + + # check maintenance request date. + self.assertEqual(maintenance_request_01.request_date, datetime.now().date() + timedelta(days=10), 'maintenance request_date is wrong') + + # Updating maintenance to Done stage and its close date + maintenance_request_01.write({'stage_id': self.stage_repaired_id}) + maintenance_request_01.close_date = datetime.now().date() + timedelta(days=15) + + # Now next preventive maintenance date = close date + period + self.assertEqual(equipment_01.next_action_date, datetime.now().date() + timedelta(days=20), 'Wrong next preventive maintenance calculated when there is maintenance done') + + # Create another request which would be in maintenance todo stage + maintenance_request_02 = self._create_request(name='Display not working', request_date=datetime.now().date() + timedelta(days=25), equipment_id=equipment_01, maintenance_type="preventive") + + # check that maintenance_request is created or not + self.assertTrue(maintenance_request_02, 'Maintenance Request not created') + + # Check next preventive maintenance date + self.assertEqual(equipment_01.next_action_date, datetime.now().date() + timedelta(days=25), 'Wrong next preventive maintenance calculated when there is one maintenance is done and another todo') + + def test_01_mrp_maintenance(self): + """ In order to check MTBF,MTTR,estimated next failure and estimated + latest failure equipment requests. + """ + + # Required for `assign_date` to be visible in the view + with self.debug_mode(): + # Create a new equipment + equipment_form = Form(self.equipment) + equipment_form.name = 'Acer Laptop' + equipment_form.maintenance_team_id = self.maintenance_team_id + equipment_form.category_id = self.category_id + equipment_form.technician_user_id = self.technician_user_id + equipment_form.assign_date = time.strftime('%Y-%m-%d') + equipment_form.serial_no = 'MT/127/18291015' + equipment_form.expected_mtbf = 2 + equipment_form.effective_date = '2017-04-13' + equipment_form.period = 5 + equipment_01 = equipment_form.save() + + # Check that equipment is created or not + self.assertTrue(equipment_01, 'Equipment not created') + + # Create maintenance requests + + # Maintenance Request Request Date + # 1) 2017-05-03 + # 2) 2017-05-23 + # 3) 2017-06-11 + + maintenance_request_01 = self._create_request(name='Some keys are not working', request_date=datetime(2017, 5, 3).date(), equipment_id=equipment_01, maintenance_type="corrective") + maintenance_request_02 = self._create_request(name='Touchpad not working', request_date=datetime(2017, 5, 23).date(), equipment_id=equipment_01, maintenance_type="corrective") + maintenance_request_03 = self._create_request(name='Battery drains fast', request_date=datetime(2017, 6, 11).date(), equipment_id=equipment_01, maintenance_type="corrective") + + # check that maintenance_request is created or not + self.assertTrue(maintenance_request_01, 'Maintenance Request not created') + self.assertTrue(maintenance_request_02, 'Maintenance Request not created') + self.assertTrue(maintenance_request_03, 'Maintenance Request not created') + + # Request Request Date Close Date diff_days + # 1) 2017-05-03 2017-05-13 10 + # 2) 2017-05-23 2017-05-28 5 + # 3) 2017-06-11 2017-06-11 0 + + # MTTR = Day used to handle maintenance request / No of request + # 5 = (10+5+0)15 / 3 + + # MTBF = Gap in days of between effective date and last request / No of request + # 19 = (2017-06-11 - 2017-04-13) 59 / 3 + + # estimated next failure = latest failure date + MTBF + # 2017-06-30 00:00:00 = 2017-06-11 + 19 + + # maintenance_request_01 write stage_id and close_date. + maintenance_request_01.write({'stage_id': self.stage_repaired_id}) + maintenance_request_01.close_date = datetime(2017, 5, 3).date() + timedelta(days=10) + self.assertEqual(maintenance_request_01.close_date, datetime(2017, 5, 13).date(), 'Wrong close date on maintenance request.') + + # maintenance_request_02 write stage_id and close_date. + maintenance_request_02.write({'stage_id': self.stage_repaired_id}) + maintenance_request_02.close_date = datetime(2017, 5, 23).date() + timedelta(days=5) + self.assertEqual(maintenance_request_02.close_date, datetime(2017, 5, 28).date(), 'Wrong close date on maintenance request.') + + # maintenance_request_03 write stage_id and close_date. + maintenance_request_03.write({'stage_id': self.stage_repaired_id}) + maintenance_request_03.close_date = maintenance_request_03.request_date + self.assertEqual(maintenance_request_03.close_date, datetime(2017, 6, 11).date(), 'Wrong close date on maintenance request.') + + # Check MTTR = Day used to handle maintenance request / No of request (15 / 3) + self.assertEqual(equipment_01.mttr, 5, 'Maintenance Equipment MTTR(Mean Time To Repair) should be 5 days') + + # Check MTBF = Gap in days of between effective date and last request / No of request + self.assertEqual(equipment_01.mtbf, 19, 'Maintenance Equipment MTBF(Mean Time Between Failure) should be 19 days') + + # Check calculation of latest failure date (should be 11-06-2017) + latest_failure_date = equipment_01.latest_failure_date + self.assertEqual(maintenance_request_03.request_date, datetime(2017, 6, 11).date(), 'Wrong request_date on maintenance request.') + self.assertEqual(latest_failure_date, maintenance_request_03.request_date, 'Wrong latest_failure_date on maintenance request.') + + # Check calculation of estimated next failure (should be 30-06-2017) + # Step-1: latest failure date + MTBF + estimated_next_failure = equipment_01.latest_failure_date + timedelta(days=equipment_01.mtbf) + self.assertEqual(estimated_next_failure, datetime(2017, 6, 30).date(), 'Wrong latest_failure_date on maintenance request.') + + def test_02_mrp_maintenance(self): + + """ In order to check cron job to create preventive request (_cron_generate_requests)""" + """ + EX: + equipment = Acer Laptop + effective_date = 25-04-2018 + period = 5 + + maintenance request + request_date = effective_date + period + 30-04-2018 = 25-04-2018 + 5 days + """ + + # Required for `assign_date` to be visible in the view + with self.debug_mode(): + # Create a new equipment + equipment_form = Form(self.equipment) + equipment_form.name = 'Acer Laptop' + equipment_form.maintenance_team_id = self.maintenance_team_id + equipment_form.category_id = self.category_id + equipment_form.technician_user_id = self.technician_user_id + equipment_form.assign_date = time.strftime('%Y-%m-%d') + equipment_form.serial_no = 'MT/127/18291015' + equipment_form.expected_mtbf = 2 + equipment_form.effective_date = datetime.now().date() + timedelta(days=5) + equipment_form.period = 5 + equipment_01 = equipment_form.save() + + # Check that equipment is created or not + self.assertTrue(equipment_01, 'Equipment not created') + + # Execute cron job. + self.equipment._cron_generate_requests() + + # Get maintenence request. + maintenance_requests = self.env['maintenance.request'].search([('equipment_id', '=', equipment_01.id)]) + + # Check whether request is created or not. + self.assertEqual(len(maintenance_requests), 1, 'Cron job execution failure or request is not created.') + + # check maintenence request request_date + self.assertEqual(maintenance_requests.request_date, equipment_01.next_action_date, "wrong request_date in maintenence request") + + # Check whether Next preventive date is changed after execution of cron job. + self.assertEqual(equipment_01.next_action_date, datetime.now().date() + timedelta(days=10), 'Wrong next preventive maintenance date after cron job execution.') diff --git a/mrp_maintenance/views/maintenance_views.xml b/mrp_maintenance/views/maintenance_views.xml new file mode 100644 index 00000000..28eb251b --- /dev/null +++ b/mrp_maintenance/views/maintenance_views.xml @@ -0,0 +1,95 @@ + ++ ++ + ++ diff --git a/mrp_maintenance/views/mrp_views.xml b/mrp_maintenance/views/mrp_views.xml new file mode 100644 index 00000000..e611a59a --- /dev/null +++ b/mrp_maintenance/views/mrp_views.xml @@ -0,0 +1,58 @@ + ++ + +maintenance.equipment.view.form.inherit.mrp +maintenance.equipment ++ + ++ + ++ ++ + ++ + +++ +days + ++ +days + +++ + + ++days + + + +maintenance.request.view.form.inherit.mrp +maintenance.request ++ + ++ ++ + + + + + ++ +++ +['|', (not workorder_id and 1 or 0, '=', 1), '|', ('workcenter_id', '=', False), ('workcenter_id.order_ids', 'in', workorder_id)] ++ + + + + + +maintenence.request.view.search.inherit.mrp +maintenance.request ++ + ++ ++ + + diff --git a/sf_base/views/base_view.xml b/sf_base/views/base_view.xml index 1b51900c..2ddc055e 100644 --- a/sf_base/views/base_view.xml +++ b/sf_base/views/base_view.xml @@ -302,8 +302,6 @@+ + +mrp.workcenter.form.inherit.maintenance +mrp.workcenter ++ + ++ ++ ++ ++ ++ + + + + + + + + +mrp.workcenter.view.kanban.inherit.maintenance +mrp.workcenter ++ + ++ ++ Maintenance +++ +mrp.production.view.form.inherit.maintenance +mrp.production ++ + + ++++ + +- - + + @@ -276,7 +287,63 @@ + ++ + \ No newline at end of file diff --git a/sf_maintenance/views/maintenance_request_views.xml b/sf_maintenance/views/maintenance_request_views.xml new file mode 100644 index 00000000..de631cf6 --- /dev/null +++ b/sf_maintenance/views/maintenance_request_views.xml @@ -0,0 +1,30 @@ + ++ + +equipment.maintenance.standards.form +equipment.maintenance.standards ++ + ++ + +equipment.maintenance.standards.tree +equipment.maintenance.standards ++ ++ ++ + + + + + + + + + + + + + +equipment.maintenance.standards.search +equipment.maintenance.standards ++ ++ ++ ++ + + + + + + + + + + + + +设备维保标准 +ir.actions.act_window +equipment.maintenance.standards +tree,form ++ + ++ 点击下方的创建按钮来添加设备维保标准。 +
++ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sf_maintenance/views/maintenance_views.xml b/sf_maintenance/views/maintenance_views.xml new file mode 100644 index 00000000..1f3b8b07 --- /dev/null +++ b/sf_maintenance/views/maintenance_views.xml @@ -0,0 +1,156 @@ + ++ + \ No newline at end of file diff --git a/sf_mrs_connect/models/res_config_setting.py b/sf_mrs_connect/models/res_config_setting.py index de7265ba..6070df77 100644 --- a/sf_mrs_connect/models/res_config_setting.py +++ b/sf_mrs_connect/models/res_config_setting.py @@ -60,75 +60,75 @@ class ResConfigSettings(models.TransientModel): # _logger.info("同步每日刀片类型列表...") # self.env['sf.blade.model'].sync_blade_model() # _logger.info("同步每日刀片类型完成") - _logger.info("同步所有刀片类型列表...") - self.env['sf.blade.model'].sync_all_blade_model() - _logger.info("同步所有刀片类型完成") + # _logger.info("同步所有刀片类型列表...") + # self.env['sf.blade.model'].sync_all_blade_model() + # _logger.info("同步所有刀片类型完成") # _logger.info("同步每日刀杆类型...") # self.env['sf.cutter.bar.model'].sync_cutter_bar_model() # _logger.info("同步每日刀杆类型完成") - _logger.info("同步所有刀杆类型...") - self.env['sf.cutter.bar.model'].sync_all_cutter_bar_model() - _logger.info("同步所有刀杆类型完成") + # _logger.info("同步所有刀杆类型...") + # self.env['sf.cutter.bar.model'].sync_all_cutter_bar_model() + # _logger.info("同步所有刀杆类型完成") # _logger.info("同步每日刀盘类型...") # self.env['sf.cutter.pad.model'].sync_cutter_pad_model() # _logger.info("同步每日刀盘类型完成") - _logger.info("同步所有刀盘类型...") - self.env['sf.cutter.pad.model'].sync_all_cutter_pad_model() - _logger.info("同步所有刀盘类型完成") + # _logger.info("同步所有刀盘类型...") + # self.env['sf.cutter.pad.model'].sync_all_cutter_pad_model() + # _logger.info("同步所有刀盘类型完成") # _logger.info("同步每日刀柄类型...") # self.env['sf.handle.model'].sync_handle_model() # _logger.info("同步每日刀柄类型完成") - _logger.info("同步所有刀柄类型...") - self.env['sf.handle.model'].sync_all_handle_model() - _logger.info("同步所有刀柄类型完成") + # _logger.info("同步所有刀柄类型...") + # self.env['sf.handle.model'].sync_all_handle_model() + # _logger.info("同步所有刀柄类型完成") # _logger.info("同步每日夹头类型...") # self.env['sf.chuck.model'].sync_chuck_model() # _logger.info("同步每日夹头类型完成") - _logger.info("同步所有夹头类型...") - self.env['sf.chuck.model'].sync_all_chuck_model() - _logger.info("同步所有夹头类型完成") + # _logger.info("同步所有夹头类型...") + # self.env['sf.chuck.model'].sync_all_chuck_model() + # _logger.info("同步所有夹头类型完成") # _logger.info("同步每日整体式刀具类型...") # self.env['sf.integral.cutting.tool.model'].sync_integral_cutting_tool_model() # _logger.info("同步每日整体式刀具类型完成") - _logger.info("同步所有整体式刀具类型...") - self.env['sf.integral.cutting.tool.model'].sync_all_integral_cutting_tool_model() - _logger.info("同步所有整体式刀具类型完成") + # _logger.info("同步所有整体式刀具类型...") + # self.env['sf.integral.cutting.tool.model'].sync_all_integral_cutting_tool_model() + # _logger.info("同步所有整体式刀具类型完成") # _logger.info("同步每日刀片列表...") # self.env['sf.blade'].sync_blade() # _logger.info("同步每日刀片完成") - _logger.info("同步所有刀片列表...") - self.env['sf.blade'].sync_all_blade() - _logger.info("同步所有刀片完成") + # _logger.info("同步所有刀片列表...") + # self.env['sf.blade'].sync_all_blade() + # _logger.info("同步所有刀片完成") # _logger.info("同步每日刀杆列表...") # self.env['sf.cutter.bar'].sync_cutter_bar() # _logger.info("同步每日刀杆完成") - _logger.info("同步所有刀杆列表...") - self.env['sf.cutter.bar'].sync_all_cutter_bar() - _logger.info("同步所有刀杆完成") - # _logger.info("同步每日刀盘列表...") - # self.env['sf.cutter.pad'].sync_cutter_pad() - # _logger.info("同步每日刀盘完成") - _logger.info("同步所有刀盘列表...") - self.env['sf.cutter.pad'].sync_all_cutter_pad() - _logger.info("同步所有刀盘完成") - # _logger.info("同步每日刀柄列表...") - # self.env['sf.handle'].sync_handle() - # _logger.info("同步每日刀柄完成") - _logger.info("同步所有刀柄列表...") - self.env['sf.handle'].sync_all_handle() - _logger.info("同步所有刀柄完成") - # _logger.info("同步每日夹头列表...") - # self.env['sf.chuck'].sync_chuck() - # _logger.info("同步每日夹头完成") - _logger.info("同步所有夹头列表...") - self.env['sf.chuck'].sync_all_chuck() - _logger.info("同步所有夹头完成") - # _logger.info("同步每日整体式刀具列表...") - # self.env['sf.integral.cutting.tool'].sync_integral_cutting_tool() - # _logger.info("同步每日整体式刀具完成") - _logger.info("同步所有整体式刀具列表...") - self.env['sf.integral.cutting.tool'].sync_all_integral_cutting_tool() - _logger.info("同步所有整体式刀具完成") + # _logger.info("同步所有刀杆列表...") + # self.env['sf.cutter.bar'].sync_all_cutter_bar() + # _logger.info("同步所有刀杆完成") + # # _logger.info("同步每日刀盘列表...") + # # self.env['sf.cutter.pad'].sync_cutter_pad() + # # _logger.info("同步每日刀盘完成") + # _logger.info("同步所有刀盘列表...") + # self.env['sf.cutter.pad'].sync_all_cutter_pad() + # _logger.info("同步所有刀盘完成") + # # _logger.info("同步每日刀柄列表...") + # # self.env['sf.handle'].sync_handle() + # # _logger.info("同步每日刀柄完成") + # _logger.info("同步所有刀柄列表...") + # self.env['sf.handle'].sync_all_handle() + # _logger.info("同步所有刀柄完成") + # # _logger.info("同步每日夹头列表...") + # # self.env['sf.chuck'].sync_chuck() + # # _logger.info("同步每日夹头完成") + # _logger.info("同步所有夹头列表...") + # self.env['sf.chuck'].sync_all_chuck() + # _logger.info("同步所有夹头完成") + # # _logger.info("同步每日整体式刀具列表...") + # # self.env['sf.integral.cutting.tool'].sync_integral_cutting_tool() + # # _logger.info("同步每日整体式刀具完成") + # _logger.info("同步所有整体式刀具列表...") + # self.env['sf.integral.cutting.tool'].sync_all_integral_cutting_tool() + # _logger.info("同步所有整体式刀具完成") # _logger.info("同步每日同步功能刀具列表...") # self.env['sf.functional.cutting.tool'].sync_functional_cutting_tool() # _logger.info("同步每日功能刀具列表完成") diff --git a/sf_tool_management/__init__.py b/sf_tool_management/__init__.py deleted file mode 100644 index c081ee06..00000000 --- a/sf_tool_management/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# -*-coding:utf-8-*- -from . import models diff --git a/sf_tool_management/__manifest__.py b/sf_tool_management/__manifest__.py deleted file mode 100644 index 8368f528..00000000 --- a/sf_tool_management/__manifest__.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. -{ - 'name': '机企猫智能工厂 刀具管理', - 'version': '1.0', - 'summary': '智能工厂刀具管理', - 'sequence': 1, - 'description': """ -在本模块,定义了主要的角色、菜单、基础业务对象 - """, - 'category': 'sf', - 'website': 'https://www.sf.jikimo.com', - 'depends': ['account', 'sf_base', 'mrp'], - 'data': [ - 'security/group_security.xml', - 'security/ir.model.access.csv', - 'views/tool_base_views.xml', - 'views/menu_view.xml', - - ], - 'demo': [ - ], - 'assets': { - - 'web.assets_qweb': [ - ], - - - }, - 'license': 'LGPL-3', - 'installable': True, - 'application': False, - 'auto_install': False, -} diff --git a/sf_tool_management/models/__init__.py b/sf_tool_management/models/__init__.py deleted file mode 100644 index c1c7e803..00000000 --- a/sf_tool_management/models/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import base - diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py deleted file mode 100644 index ae13cb56..00000000 --- a/sf_tool_management/models/base.py +++ /dev/null @@ -1,99 +0,0 @@ -# -*- coding: utf-8 -*- -from odoo import fields, models, api - - -class FunctionalCuttingToolEntity(models.Model): - _name = 'sf.functional.cutting.tool.entity' - _inherit = 'sf.functional.cutting.tool' - _description = '功能刀具管理' - - order = fields.Char(string='序') - functional_cutting_tool_id = fields.Many2one('sf.functional.cutting.tool', string='功能刀具', invisible=True) - # 功能刀具预警 特有字段 - install_tool_time = fields.Char("装刀时间") - outbound_time = fields.Char('出库时间') - on_board_time = fields.Char('上机时间') - machine_tool_code = fields.Char('机台号') - cutting_tool_code = fields.Char('刀位号') - idle_time = fields.Char('闲置时长') - alarm_value = fields.Char('报警值') - used_value = fields.Char('已使用值') - alarm_type = fields.Char('报警类型') - alarm_time = fields.Char('报警时间') - dispose_user = fields.Char('处理人') - dispose_time = fields.Char('处理时间') - dispose_func = fields.Char('处理方法/措施') - remark = fields.Char('备注') - - # 功能刀具出入库记录 特有字段 - thickness = fields.Selection([('1', '粗'), ('2', '中'), ('3', '细')], string='粗/中/细') - max_life_span = fields.Char(string='最大寿命值') - # alarm_value = fields.Char(string='报警值') - # used_value = fields.Char(string='已使用值') - current_state = fields.Char(string='当前状态') - current_store_area = fields.Char(string='当前库区') - current_store_place = fields.Char(string='当前库位') - number = fields.Integer(string='数量') - reason_application = fields.Char(string='申请原因') - applicant = fields.Char(string='申请人') - return_staff = fields.Char(string='归还人') - return_time = fields.Date(string='归还入库时间') - tool_state = fields.Char(string="刀具状态") - tool_install_staff = fields.Char(string='装刀人') - tool_install_time = fields.Datetime(string='装刀时间') - receive_equipment = fields.Char(string='领用机台') - receive_staff = fields.Char(string='领用人') - receive_time = fields.Char(string='领用出库时间') - # remark = fields.Text(string='备注/说明') - - # 功能刀具实时分布 - tool_stock_num = fields.Text(string='刀具房库存数量') - side_shelf_num = fields.Text(string='线边货架货架数量') - on_tool_stock_num = fields.Text(string='机内刀库库存数量') - tool_stock_total = fields.Text(string='合计') - return_reuse_num_re = fields.Text(string='归还再用数量(精)') - return_reuse_num_co = fields.Text(string='归还再用数量(粗)') - return_processing_num = fields.Text(string='归还需磨削数量') - return_total = fields.Text(string='合计') - total = fields.Text(string='总计') - # remark = fields.Text(string='备注/说明') - - # @api.onchange('functional_cutting_tool_id') - # def get_functional_cutting_tool_info(self): - # for item in self: - # item.code = item.functional_cutting_tool_id.code, - # item.name = item.functional_cutting_tool_id.name, - # item.functional_model_number = item.functional_cutting_tool_id.functional_model_number, - # item.integral_model_number = item.functional_cutting_tool_id.integral_model_number, - # item.blade_model_number = item.functional_cutting_tool_id.blade_model_number, - # item.cutterbar_model_number = item.functional_cutting_tool_id.cutterbar_model_number, - # item.cutterpad_model_number = item.functional_cutting_tool_id.cutterpad_model_number, - # item.handle_model_number = item.functional_cutting_tool_id.handle_model_number, - # item.chuck_model_number = item.functional_cutting_tool_id.chuck_model_number, - # item.diameter = item.functional_cutting_tool_id.diameter, - # item.tool_grade = item.functional_cutting_tool_id.tool_grade, - # item.machining_accuracy = item.functional_cutting_tool_id.machining_accuracy, - # item.ctool_lengthode = item.functional_cutting_tool_id.tool_length, - # item.blade_number = item.functional_cutting_tool_id.blade_number, - # item.integral_blade_length = item.functional_cutting_tool_id.integral_blade_length, - # item.effective_blade_length = item.functional_cutting_tool_id.effective_blade_length, - # item.max_life = item.functional_cutting_tool_id.max_life, - # item.is_standard = item.functional_cutting_tool_id.is_standard, - # item.applicable_range = item.functional_cutting_tool_id.applicable_range, - - @api.model - def create(self, vals): - - if not vals.get('order'): - vals['order'] = self._generate_code() - return super(FunctionalCuttingToolEntity, self).create(vals) - - @api.model - def _generate_code(self): - last_tool = self.search([], order='id desc', limit=1) - if last_tool: - last_code = int(last_tool.code.split('-')[-1]) - new_code = '{:03d}'.format(last_code + 1) - else: - new_code = '001' - return new_code diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv deleted file mode 100644 index 3156f716..00000000 --- a/sf_tool_management/security/ir.model.access.csv +++ /dev/null @@ -1,7 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_sf_functional_cutting_tool_entity,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,base.group_user,1,1,1,1 - - - - - diff --git a/sf_tool_management/views/menu_view.xml b/sf_tool_management/views/menu_view.xml deleted file mode 100644 index 5791bf90..00000000 --- a/sf_tool_management/views/menu_view.xml +++ /dev/null @@ -1,53 +0,0 @@ - -+ + +sf.maintenance.equipment.category +maintenance.equipment.category ++ + ++ ++ + + +sf_equipment.form +maintenance.equipment ++ + + ++ ++ + + + + + ++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + +++ + + + + + + + + + ++ + + + + + + ++ ++ + + + + ++ + + + + ++ + + + ++ + ++ days + +++ hours + + + + + +sf_equipment.view.search +maintenance.equipment ++ + + ++ + ++ ++ + + + + + + +sf.maintenance.hr.equipment.view.tree.inherit +maintenance.equipment ++ + ++ ++ + ++ + - - - \ No newline at end of file diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml deleted file mode 100644 index 8e44b693..00000000 --- a/sf_tool_management/views/tool_base_views.xml +++ /dev/null @@ -1,193 +0,0 @@ - -- - - - - - - - - - - - - - - -功能刀具预警 -ir.actions.act_window -sf.functional.cutting.tool.entity -tree -- - - From cf91ef5604b5037f924b0178036887e00a2c9bee Mon Sep 17 00:00:00 2001 From: "qihao.gong@jikimo.com"- - -sf.functional.cutting.tool.entity.list.tree -sf.functional.cutting.tool.entity -- -- -- - - - - - - - - - - - - - - - - - - - - - - - -功能刀具列表 -ir.actions.act_window -sf.functional.cutting.tool.entity -tree -- - - -sf.functional.cutting.tool.entity.tree -sf.functional.cutting.tool.entity -- -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - -功能刀具预警 -ir.actions.act_window -sf.functional.cutting.tool.entity -tree -- - - -功能刀具出入库记录 -sf.functional.cutting.tool.entity -- -- - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -功能刀具出入库记录 -ir.actions.act_window -sf.functional.cutting.tool.entity -tree -- - - -功能刀具实时分布 -sf.functional.cutting.tool.entity -- -- - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -功能刀具实时分布 -ir.actions.act_window -sf.functional.cutting.tool.entity -tree -- Date: Mon, 26 Jun 2023 17:32:56 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=BB=B4=E4=BF=9D?= =?UTF-8?q?=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_maintenance/models/__init__.py | 3 +- .../sf_equipment_maintenance_standards.py | 2 +- sf_maintenance/models/sf_maintenance.py | 28 +++++---- .../models/sf_maintenance_requests.py | 15 +++++ .../views/maintenance_request_views.xml | 63 ++++++++++++++----- sf_maintenance/views/maintenance_views.xml | 48 +++++++------- 6 files changed, 109 insertions(+), 50 deletions(-) diff --git a/sf_maintenance/models/__init__.py b/sf_maintenance/models/__init__.py index cf75b7d8..130f2688 100644 --- a/sf_maintenance/models/__init__.py +++ b/sf_maintenance/models/__init__.py @@ -1,3 +1,4 @@ # -*-coding:utf-8-*- from . import sf_maintenance -from . import sf_equipment_maintenance_standards \ No newline at end of file +from . import sf_equipment_maintenance_standards +from . import sf_maintenance_requests \ No newline at end of file diff --git a/sf_maintenance/models/sf_equipment_maintenance_standards.py b/sf_maintenance/models/sf_equipment_maintenance_standards.py index 9de3a2d9..0d290e49 100644 --- a/sf_maintenance/models/sf_equipment_maintenance_standards.py +++ b/sf_maintenance/models/sf_equipment_maintenance_standards.py @@ -23,6 +23,6 @@ class SfEquipmentSaintenanceStandards(models.Model): name = fields.Char(string='名称') created_user_id = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user) maintenance_equipment_category_id = fields.Many2one('maintenance.equipment.category', string='设备类别') - maintenance_equipment_ids = fields.Many2many('maintenance.equipment', 'equipment_maintenance_standards_ids', string='设备') + maintenance_equipment_ids = fields.Many2many('maintenance.equipment', 'sf_maintenance_equipment_ids', string='设备') maintenance_projects = fields.Char('维保项目') maintenance_standards = fields.Char('维保标准') diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index d8ee1af5..6c2f1dcd 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -33,7 +33,7 @@ class SfMaintenanceEquipment(models.Model): num = "%04d" % m return num - equipment_maintenance_standards_ids = fields.Many2many('equipment.maintenance.standards', 'maintenance_equipment_ids', string='设备维保标准') + equipment_maintenance_standards_ids = fields.Many2many('equipment.maintenance.standards', 'sf_maintenance_equipment_ids', string='设备维保标准') eq_maintenance_id =fields.Many2one('equipment.maintenance.standards', string='设备保养标准', domain="[('maintenance_type','=','保养')]") overhaul_date = fields.Date(string='下次预防检修') overhaul_period = fields.Integer(string='预防检修频次') @@ -41,17 +41,21 @@ class SfMaintenanceEquipment(models.Model): overhaul_id = fields.Many2one('equipment.maintenance.standards', string='设备检修标准', domain="[('maintenance_type','=','检修')]") - # @api.depends('eq_maintenance_id', 'overhaul_id') - # def _compute_equipment_maintenance_standards_ids(self): - # for record in self: - # if record.eq_maintenance_id == False: - # record.equipment_maintenance_standards_ids = [ - # (6, 0, [record.overhaul_id.id]),(3,record.eq_maintenance_id.id,0)] - # if record.overhaul_id == False: - # record.equipment_maintenance_standards_ids = [ - # (6, 0, [record.eq_maintenance_id.id]),(3,record.overhaul_id.id,0)] - # else: - # record.equipment_maintenance_standards_ids = [(6, 0, [record.eq_maintenance_id.id, record.overhaul_id.id])] + @api.onchange('eq_maintenance_id', 'overhaul_id') + def _compute_equipment_maintenance_standards_ids(self): + for record in self: + if record.eq_maintenance_id and record.overhaul_id: + record.equipment_maintenance_standards_ids = [(6, 0, [record.eq_maintenance_id.id, record.overhaul_id.id])] + break + if record.eq_maintenance_id: + record.equipment_maintenance_standards_ids = [(6, 0, [record.eq_maintenance_id.id])] + break + if record.overhaul_id: + record.equipment_maintenance_standards_ids = [(6, 0, [record.overhaul_id.id])] + break + else: + record.equipment_maintenance_standards_ids = False + MTcode = fields.Char("编码", default=get_no) diff --git a/sf_maintenance/models/sf_maintenance_requests.py b/sf_maintenance/models/sf_maintenance_requests.py index 1bf528dc..1d623892 100644 --- a/sf_maintenance/models/sf_maintenance_requests.py +++ b/sf_maintenance/models/sf_maintenance_requests.py @@ -9,5 +9,20 @@ class SfMaintenanceEquipmentCategory(models.Model): _inherit = 'maintenance.request' _description = '维保计划' + sf_maintenance_type = fields.Selection([('保养', '保养'), ('检修', '检修')], string='维保类别', default='保养') + + equipment_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备维保标准', + domain="[('maintenance_type','=',sf_maintenance_type)]") + + @api.onchange('sf_maintenance_type') + def _compute_equipment_maintenance_request_id(self): + for record in self: + if record.sf_maintenance_type == '保养': + record.equipment_maintenance_id = record.equipment_id.eq_maintenance_id + if record.sf_maintenance_type == '检修': + record.equipment_maintenance_id = record.equipment_id.overhaul_id + if not record.equipment_maintenance_id: + raise UserError(_("设备没有配置维保标准,请配置后再保存")) + diff --git a/sf_maintenance/views/maintenance_request_views.xml b/sf_maintenance/views/maintenance_request_views.xml index de631cf6..b3f257b1 100644 --- a/sf_maintenance/views/maintenance_request_views.xml +++ b/sf_maintenance/views/maintenance_request_views.xml @@ -1,20 +1,53 @@ - - - - - - - - - - - - - - + + \ No newline at end of file diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 22c780cd..54372dfc 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -164,6 +164,7 @@+ + + + + + +sf.equipment.request.form +maintenance.request ++ + ++ + + + + + + + + + + + + + + + ++ + + + @@ -22,7 +55,7 @@ id="menu_m_request_form" name="维保计划" parent="maintenance.menu_m_request" - action="maintenance.hr_equipment_request_action" + action="hr_equipment_request_action" groups="maintenance.group_equipment_manager,base.group_user" sequence="1"/> diff --git a/sf_maintenance/views/maintenance_views.xml b/sf_maintenance/views/maintenance_views.xml index 1f3b8b07..6b4ee016 100644 --- a/sf_maintenance/views/maintenance_views.xml +++ b/sf_maintenance/views/maintenance_views.xml @@ -18,33 +18,30 @@维保计划 +maintenance.request +kanban,tree,form,pivot,graph,calendar ++ {'default_user_id': uid} ++ ++ Add a new maintenance request +
+ Follow the process of the request and communicate with the collaborator. +
++ + + - - + + + - + From 1348712c837243c17d6cff959e9483882360095b Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Mon, 26 Jun 2023 18:10:37 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=BA=86=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E8=AE=A1=E5=88=92=E7=9A=84=E6=8C=89=E9=94=AE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E4=BB=A5=E5=8F=8A=E6=8C=89=E9=94=AE=E7=9A=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 128 +++++++++++++----- .../security/ir.model.access.csv | 2 + sf_tool_management/views/menu_view.xml | 9 ++ sf_tool_management/views/tool_base_views.xml | 77 ++++++++++- sf_tool_management/wizard/wizard.py | 49 ++++++- 5 files changed, 219 insertions(+), 46 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index d4d1a7ba..333d1723 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -139,35 +139,23 @@ class MachineTableToolChangingApply(models.Model): reason_for_applying = fields.Char(string='申请原因') remark = fields.Char(string='备注说明') - # def sync_tool_entity_from_tool_changing_apply_table(self): - # """ - # ‘功能刀具预警’数据同步到‘机床换刀申请’ - # """ - # # 获取源表中的所有记录 - # source_records = self.env['sf.functional.cutting.tool.entity'].search([]) - # - # # 循环遍历每个记录 - # for source_record in source_records: - # # 检查目标表中是否存在相同的记录 - # destination_record = self.search([('CNC_machine_table', '=', source_record.machine_tool_code)]) - # if destination_record: - # # todo 如果目标表中已经存在相同的记录,则更新该记录 - # destination_record.name = source_record.name - # else: - # # todo 如果目标表中不存在相同的记录,则创建一个新记录 - # destination_record = self.create({ - # # 'name': source_record.name, - # }) + status = fields.Selection([('0', '未操作'), ('1', '已换刀申请'), ('2', '已转移')], string='操作状态', default='0') - def amendant_record(self, vals): + def new_assembly_task(self,vals): """ - 确认换刀申请(按键) - 将弹窗数据更新到记录 + 新建组装任务 :param vals: :return: """ - self.env['sf.machine.table.tool.changing.apply'].search( - [('CNC_machine_table', '=', vals.get('CNC_machine_table'))]).write(vals) + # todo 设置直径的值 + # tool_changing_apply = self.env['sf.machine.table.tool.changing.apply'].search( + # [('CNC_machine_table', '=', vals.get('CNC_machine_table'))]) + # for i in tool_changing_apply: + # print(i) + # vals['functional_tool_diameter'] = tool_changing_apply.diameter + + self.env['sf.functional.tool.assembly'].create(vals) + def revocation_1(self): """ @@ -175,26 +163,33 @@ class MachineTableToolChangingApply(models.Model): :return: """ # 撤回数据更新 - self.env['sf.machine.table.tool.changing.apply'].search( - [('CNC_machine_table', '=', self.CNC_machine_table)]).write({ - 'replacement_tool_code': False, - 'replacement_tool_name': False, - 'replacement_tool_type': False, - 'replacement_tool_coarse_middle_thin': False, - 'new_former': False, - 'applicant': False, - 'used_tool_time': False, - 'reason_for_applying': False, - 'remark': False + self.env['sf.machine.table.tool.changing.apply'].search([('CNC_machine_table', '=', self.CNC_machine_table)]).write({ + 'replacement_tool_code': None, + 'replacement_tool_name': None, + 'replacement_tool_type': None, + 'replacement_tool_coarse_middle_thin': None, + 'new_former': None, + 'applicant': None, + 'used_tool_time': None, + 'reason_for_applying': None, + 'remark': None, + 'status': '0' }) - # todo 撤回功能刀具组装创建新任务 + # 撤回功能刀具组装创建新任务 + self.env['sf.functional.tool.assembly'].search( + [('functional_tool_code', '=', self.functional_tool_code)]).unlink() - def revocation_1(self): + + def revocation_2(self): """ 转移撤回按键 :return: """ + self.env['sf.machine.table.tool.changing.apply'].search( + [('CNC_machine_table', '=', self.CNC_machine_table)]).write({ + 'status': '0' + }) class CAMWorkOrderProgramKnifePlan(models.Model): @@ -222,3 +217,62 @@ class CAMWorkOrderProgramKnifePlan(models.Model): applicant = fields.Char(string='申请人') reason_for_applying = fields.Char(string='申请原因') remark = fields.Char(string='备注说明') + + def revocation(self): + """ + 撤回装刀申请 + :return: + """ + self.env['sf.functional.tool.assembly'].search( + [('functional_tool_code', '=', self.functional_tool_code)]).unlink() + + # 将计划执行状态改为待执行 + self.env['sf.cam.work.order.program.knife.plan'].search( + [('functional_tool_code', '=', self.functional_tool_code)]).write({'plan_execute_status': '0'}) + + + + + +class FunctionalToolAssembly(models.Model): + _name = 'sf.functional.tool.assembly' + _description = '功能刀具组装' + + functional_tool_code = fields.Char(string='功能刀具编码') + functional_tool_name = fields.Char(string='功能刀具名称') + functional_tool_type = fields.Char(string='功能刀具类型') + functional_tool_diameter = fields.Char(string='功能刀具直径') + functional_tool_length = fields.Char(string='功能刀具伸出长') + functional_tool_cutting_type = fields.Char(string='功能刀具切削类型') + + tool_name = fields.Char(string='刀具名称') + tool_brand = fields.Char(string='品牌') + tool_type = fields.Char(string='型号') + knife_handle_name = fields.Char(string='刀柄名称') + knife_handle_brand = fields.Char(string='品牌') + knife_handle_type = fields.Char(string='型号') + + coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精') + tool_loading_length = fields.Char(string='装刀长') + new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧') + reference_length = fields.Char(string='参考伸出长') + cut_time = fields.Char(string='已切削时间') + cut_length = fields.Char(string='已切削长度') + cut_number = fields.Char(string='已切削次数') + + loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀')], string='装刀任务来源') + applicant = fields.Char(string='申请人') + reason_for_applying = fields.Char(string='申请原因') + apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now()) + + assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装'), ('2', '已出库')],string='组装状态', default='0') + use_tool_time = fields.Datetime(string='用刀时间') + production_line_name = fields.Char(string='产线名称') + machine_tool_name = fields.Char(string='机床名称') + machine_tool_code = fields.Char(string='机台号') + cutter_spacing_code = fields.Char(string='刀位号') + tool_loading_person = fields.Char(string='装刀人') + tool_loading_time = fields.Datetime(string='装刀时间') + receive_person = fields.Char(string='领用人') + receive_time = fields.Datetime(string='领用出库时间') + remark = fields.Char(string='备注说明') diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv index e97c88f8..e481edaa 100644 --- a/sf_tool_management/security/ir.model.access.csv +++ b/sf_tool_management/security/ir.model.access.csv @@ -8,6 +8,8 @@ access_sf_tool_change_requirement_information,sf.tool.change.requirement.informa access_sf_tool_transfer_request_information,sf.tool.transfer.request.information,model_sf_tool_transfer_request_information,base.group_user,1,1,1,1 access_sf_apply_for_tooling,sf.apply.for.tooling,model_sf_apply_for_tooling,base.group_user,1,1,1,1 +access_sf_functional_tool_assembly,sf.functional.tool.assembly,model_sf_functional_tool_assembly,base.group_user,1,1,1,1 + diff --git a/sf_tool_management/views/menu_view.xml b/sf_tool_management/views/menu_view.xml index b0fc131c..fbb58dda 100644 --- a/sf_tool_management/views/menu_view.xml +++ b/sf_tool_management/views/menu_view.xml @@ -72,5 +72,14 @@ parent="menu_sf_function_tool_plan" /> + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -112,7 +118,7 @@ hours - + + - + - - - + + + + @@ -261,9 +266,15 @@ 'default_coarse_middle_thin': coarse_middle_thin, 'default_whether_standard_tool': whether_standard_tool, 'default_need_knife_time': need_knife_time, + 'default_applicant': applicant, 'default_required_cutting_time': required_cutting_time, 'default_reason_for_applying': reason_for_applying}" + class="btn-primary" + attrs="{'invisible': [('plan_execute_status', '!=', '0')]}" /> + + + + + +CAM工单程序用刀计划 +sf.functional.tool.assembly ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 60fcfd86..fe986fff 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -40,12 +40,26 @@ class ToolChangeRequirementInformation(models.TransientModel): 'applicant': self.applicant, 'used_tool_time': self.used_tool_time, 'reason_for_applying': self.reason_for_applying, - 'remark': self.new_former + 'remark': self.new_former, + 'status': '1' } # 将数据更新到换刀申请 - self.env['sf.machine.table.tool.changing.apply'].amendant_record(desc) + self.env['sf.machine.table.tool.changing.apply'].search( + [('CNC_machine_table', '=', desc.get('CNC_machine_table'))]).write(desc) - # todo 功能刀具组装创建新任务 + # 功能刀具组装创建新任务 + self.env['sf.machine.table.tool.changing.apply'].new_assembly_task({ + 'functional_tool_code': self.replacement_tool_code, + 'functional_tool_name': self.replacement_tool_name, + 'functional_tool_type': self.replacement_tool_type, + 'loading_task_source': '1', + 'applicant': self.applicant, + 'reason_for_applying': self.reason_for_applying, + 'use_tool_time': self.used_tool_time, + 'machine_tool_name': self.CNC_machine_table, + 'machine_tool_code': self.machine_tool_code, + 'cutter_spacing_code': self.cutter_spacing_code + }) # 关闭弹出窗口 return {'type': 'ir.actions.act_window_close'} @@ -81,6 +95,8 @@ class ToolTransferRequestInformation(models.TransientModel): 刀具转移申请信息确定按钮 :return: """ + self.env['sf.machine.table.tool.changing.apply'].search( + [('CNC_machine_table', '=', self.CNC_machine_table)]).write({'status': '2'}) class ApplyForTooling(models.TransientModel): @@ -107,11 +123,36 @@ class ApplyForTooling(models.TransientModel): required_cutting_time = fields.Char(string='需要切割时间', readonly=True) reason_for_applying = fields.Char(string='申请原因', readonly=True) + applicant = fields.Char(string='申请人', invisible='1') + def apply_for_tooling(self): """ - + 申请装刀 :return: """ + self.env['sf.functional.tool.assembly'].create({ + 'functional_tool_code': self.functional_tool_code, + 'functional_tool_name': self.functional_tool_name, + 'functional_tool_type': self.functional_tool_type, + 'functional_tool_diameter': self.diameter, + 'functional_tool_length': self.tool_loading_length, + 'loading_task_source': '0', + 'coarse_middle_thin': None, + 'tool_loading_length': None, + 'applicant': self.applicant, + 'reason_for_applying': self.reason_for_applying, + 'use_tool_time': self.need_knife_time, + 'machine_tool_name': self.machine_table_name, + 'machine_tool_code': self.cam_procedure_code, + 'cutter_spacing_code': self.cam_cutter_spacing_code + }) + + # 将计划执行状态改为执行中 + self.env['sf.cam.work.order.program.knife.plan'].search( + [('functional_tool_code', '=', self.functional_tool_code)]).write({'plan_execute_status': '1'}) + + # 关闭弹出窗口 + return {'type': 'ir.actions.act_window_close'} From e880b020c6560d4287ff86c0f8e505def6929207 Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Tue, 27 Jun 2023 10:20:31 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=9C=BA?= =?UTF-8?q?=E5=8F=B0=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E5=92=8CCAM?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=94=A8=E5=88=80=E8=AE=A1=E5=88=92=E7=9A=84?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=A7=86=E5=9B=BE=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E6=9C=BA=E5=8F=B0=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E7=9A=84=E8=87=AA=E5=8A=A8=E6=8D=A2=E5=88=80=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86CAM=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E7=94=A8=E5=88=80=E8=AE=A1=E5=88=92=E7=9A=84=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E5=8A=9F=E8=83=BD=EF=BC=88?= =?UTF-8?q?=E5=BE=85=E5=AE=8C=E5=96=84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 52 +++++++- sf_tool_management/views/tool_base_views.xml | 119 +++++++++++++++++-- sf_tool_management/wizard/wizard.py | 2 +- 3 files changed, 161 insertions(+), 12 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 333d1723..85cb2c9a 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -126,7 +126,7 @@ class MachineTableToolChangingApply(models.Model): max_lifetime_value = fields.Char(string='最大寿命值') alarm_value = fields.Char(string='报警值') used_value = fields.Char(string='已使用值') - functional_tool_status = fields.Selection([('正常', '正常'), ('异常', '异常')], string='功能刀具状态') + functional_tool_status = fields.Selection([('正常', '正常'), ('异常', '异常')], string='功能刀具状态', default='正常') replacement_tool_code = fields.Char(string='待换刀具编码') replacement_tool_name = fields.Char(string='待换刀具名称') @@ -141,18 +141,58 @@ class MachineTableToolChangingApply(models.Model): status = fields.Selection([('0', '未操作'), ('1', '已换刀申请'), ('2', '已转移')], string='操作状态', default='0') + @api.onchange('functional_tool_status') + def automation_apply_for_tool_change(self): + """ + 自动申请换刀 + :return: + """ + # 更新数据到机台换刀申请界面 + # todo 换刀申请条件需补充完善 + if(self.functional_tool_status == '异常'): + self.env['sf.machine.table.tool.changing.apply'].search([ + ('CNC_machine_table', '=', self.CNC_machine_table)]).write({ + 'replacement_tool_code': self.functional_tool_code, + 'replacement_tool_name': self.functional_tool_name, + 'replacement_tool_type': self.functional_tool_type, + 'replacement_tool_coarse_middle_thin': self.coarse_middle_thin, + 'new_former': '0', + 'applicant': '自动申请', + 'used_tool_time': fields.Datetime.now(), + 'reason_for_applying': '功能刀具状态异常', + 'remark': None, + 'status': '1' + }) + + # 新建组装任务 + self.env['sf.functional.tool.assembly'].create({ + 'functional_tool_code': self.functional_tool_code, + 'functional_tool_name': self.functional_tool_name, + 'functional_tool_type': self.functional_tool_type, + 'functional_tool_diameter': self.diameter, + 'loading_task_source': '1', + 'applicant': self.applicant, + 'reason_for_applying': self.reason_for_applying, + 'use_tool_time': self.used_tool_time, + 'machine_tool_name': self.CNC_machine_table, + 'machine_tool_code': self.machine_tool_code, + 'cutter_spacing_code': self.cutter_spacing_code + }) + + + def new_assembly_task(self,vals): """ 新建组装任务 :param vals: :return: """ - # todo 设置直径的值 + # todo 增加设置直径的值 # tool_changing_apply = self.env['sf.machine.table.tool.changing.apply'].search( # [('CNC_machine_table', '=', vals.get('CNC_machine_table'))]) # for i in tool_changing_apply: # print(i) - # vals['functional_tool_diameter'] = tool_changing_apply.diameter + # vals['functional_tool_diameter'] = self.diameter self.env['sf.functional.tool.assembly'].create(vals) @@ -218,6 +258,12 @@ class CAMWorkOrderProgramKnifePlan(models.Model): reason_for_applying = fields.Char(string='申请原因') remark = fields.Char(string='备注说明') + def automation_apply_for_tooling(self): + """ + todo 自动申请装刀 + :return: + """ + def revocation(self): """ 撤回装刀申请 diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 54372dfc..fbc25af9 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -176,10 +176,10 @@ 'default_replacement_tool_name': functional_tool_name, 'default_replacement_tool_type': functional_tool_type, 'default_replacement_tool_coarse_middle_thin': coarse_middle_thin}" - attrs="{'invisible': ['|',('functional_tool_status', '=', '正常'), ('status', '!=', '0')]}" + attrs="{'invisible': [('status', '!=', '0')]}" class="btn-primary" /> -CAM工单程序用刀计划 +ir.actions.act_window +sf.functional.tool.assembly +tree,form ++ + + +sf.machine.table.tool.changing.apply ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + @@ -279,17 +311,46 @@ + 机床换刀申请 ir.actions.act_window sf.machine.table.tool.changing.apply -tree,form +tree,form,search + +sf.cam.work.order.program.knife.plan ++ ++ ++ + + + + + + + + + + + + + + + + + + + + - + CAM工单程序用刀计划 ir.actions.act_window sf.cam.work.order.program.knife.plan -tree,form +tree,form,search - +CAM工单程序用刀计划 +功能刀具组装 sf.functional.tool.assembly @@ -338,11 +399,53 @@ + +sf.functional.tool.assembly ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index fe986fff..f70994b3 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -43,7 +43,7 @@ class ToolChangeRequirementInformation(models.TransientModel): 'remark': self.new_former, 'status': '1' } - # 将数据更新到换刀申请 + # 将数据更新到机台换刀申请界面 self.env['sf.machine.table.tool.changing.apply'].search( [('CNC_machine_table', '=', desc.get('CNC_machine_table'))]).write(desc) From d6f749fff5c3575b9301828b05750fe0d7d6bab3 Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Tue, 27 Jun 2023 17:31:49 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E7=9A=84=E7=BB=84=E8=A3=85?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E6=8C=89=E9=94=AE=E5=8A=9F=E8=83=BD=EF=BC=88?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=B7=B2=E5=AE=8C=E6=88=90=EF=BC=89=E3=80=81?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E7=BB=84=E8=A3=85=E5=8A=9F=E8=83=BD=E6=8C=89?= =?UTF-8?q?=E9=94=AE=EF=BC=88=E5=8A=9F=E8=83=BD=E5=B7=B2=E5=AE=8C=E6=88=90?= =?UTF-8?q?=EF=BC=89=E3=80=81=E5=87=BA=E5=BA=93=E5=BC=B9=E7=AA=97=E6=8C=89?= =?UTF-8?q?=E9=94=AE=EF=BC=88=E5=B7=B2=E5=AE=8C=E6=88=90=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 49 +++++++- .../security/ir.model.access.csv | 2 + sf_tool_management/views/tool_base_views.xml | 46 ++++++- sf_tool_management/wizard/wizard.py | 81 +++++++++++- sf_tool_management/wizard/wizard_view.xml | 115 ++++++++++++++++++ 5 files changed, 283 insertions(+), 10 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 85cb2c9a..8563fed3 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -157,9 +157,9 @@ class MachineTableToolChangingApply(models.Model): 'replacement_tool_type': self.functional_tool_type, 'replacement_tool_coarse_middle_thin': self.coarse_middle_thin, 'new_former': '0', - 'applicant': '自动申请', + 'applicant': None, 'used_tool_time': fields.Datetime.now(), - 'reason_for_applying': '功能刀具状态异常', + 'reason_for_applying': None, 'remark': None, 'status': '1' }) @@ -263,6 +263,26 @@ class CAMWorkOrderProgramKnifePlan(models.Model): todo 自动申请装刀 :return: """ + self.env['sf.functional.tool.assembly'].create({ + 'functional_tool_code': self.functional_tool_code, + 'functional_tool_name': self.functional_tool_name, + 'functional_tool_type': self.functional_tool_type, + 'functional_tool_diameter': self.diameter, + 'functional_tool_length': self.tool_loading_length, + 'loading_task_source': '0', + 'coarse_middle_thin': None, + 'tool_loading_length': None, + 'applicant': self.applicant, + 'reason_for_applying': self.reason_for_applying, + 'use_tool_time': self.need_knife_time, + 'machine_tool_name': self.machine_table_name, + 'machine_tool_code': self.cam_procedure_code, + 'cutter_spacing_code': self.cam_cutter_spacing_code + }) + + # 将计划执行状态改为执行中 + self.env['sf.cam.work.order.program.knife.plan'].search( + [('functional_tool_code', '=', self.functional_tool_code)]).write({'plan_execute_status': '1'}) def revocation(self): """ @@ -322,3 +342,28 @@ class FunctionalToolAssembly(models.Model): receive_person = fields.Char(string='领用人') receive_time = fields.Datetime(string='领用出库时间') remark = fields.Char(string='备注说明') + + def cancel_functional_tool_assembly(self): + """ + 取消功能刀具组装 + :return: + """ + self.env['sf.functional.tool.assembly'].search([ + ('machine_tool_name', '=', self.machine_tool_name), + ('cutter_spacing_code', '=', self.cutter_spacing_code) + ]).write({ + 'tool_name': None, + 'tool_brand': None, + 'tool_type': None, + 'knife_handle_name': None, + 'knife_handle_brand': None, + 'knife_handle_type': None, + 'coarse_middle_thin': None, + 'tool_loading_length': None, + 'new_former': None, + 'reference_length': None, + 'cut_time': None, + 'cut_length': None, + 'cut_number': None, + 'assemble_status': '0' + }) diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv index e481edaa..1792b613 100644 --- a/sf_tool_management/security/ir.model.access.csv +++ b/sf_tool_management/security/ir.model.access.csv @@ -9,6 +9,8 @@ access_sf_tool_transfer_request_information,sf.tool.transfer.request.information access_sf_apply_for_tooling,sf.apply.for.tooling,model_sf_apply_for_tooling,base.group_user,1,1,1,1 access_sf_functional_tool_assembly,sf.functional.tool.assembly,model_sf_functional_tool_assembly,base.group_user,1,1,1,1 +access_sf_functional_tool_assembly_order,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,base.group_user,1,1,1,1 +access_sf_delivery_of_cargo_from_storage,sf.delivery.of.cargo.from.storage,model_sf_delivery_of_cargo_from_storage,base.group_user,1,1,1,1 diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index fbc25af9..d653668a 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -378,11 +378,47 @@CAM工单程序用刀计划 +功能刀具组装 ir.actions.act_window sf.functional.tool.assembly -tree,form +tree,form,search - - - - - + + + + + + + + + + + + + diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index f70994b3..22a5a0d7 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -155,10 +155,85 @@ class ApplyForTooling(models.TransientModel): return {'type': 'ir.actions.act_window_close'} +class FunctionalToolAssemblyOrder(models.TransientModel): + _name = 'sf.functional.tool.assembly.order' + _description = '功能刀具组装单' + + # 功能刀具申请信息 + machine_tool_name = fields.Char(string='机床名称', readonly=True) + cutter_spacing_code = fields.Char(string='刀位号', readonly=True) + functional_tool_name = fields.Char(string='功能刀具名称', readonly=True) + functional_tool_type = fields.Char(string='功能刀具类型', readonly=True) + functional_tool_length = fields.Char(string='功能刀具伸出长', readonly=True) + effective_length = fields.Char(string='有效长', readonly=True) + functional_tool_diameter = fields.Char(string='功能刀具直径', readonly=True) + tool_included_angle = fields.Char(string='刀尖角(R角)', readonly=True) + functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=True) + required_cutting_time = fields.Char(string='需要切割时间', readonly=True) + whether_standard_tool = fields.Boolean(string='是否标准刀', readonly=True) + + # 功能刀具组装信息 + tool_name = fields.Char(string='刀具名称') + tool_code = fields.Char(string='刀具编码') + tool_brand = fields.Char(string='品牌') + tool_type = fields.Char(string='型号') + knife_handle_name = fields.Char(string='刀柄名称') + knife_handle_code = fields.Char(string='刀柄编码') + knife_handle_brand = fields.Char(string='品牌') + knife_handle_type = fields.Char(string='型号') + coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精') + tool_loading_length = fields.Char(string='装刀长') + new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧') + reference_length = fields.Char(string='参考伸出长') + cut_time = fields.Char(string='已切削时间') + cut_length = fields.Char(string='已切削长度') + cut_number = fields.Char(string='已切削次数') + + def functional_tool_assembly(self): + """ + 功能刀具组装 + :return: + """ + self.env['sf.functional.tool.assembly'].search([ + ('machine_tool_name', '=', self.machine_tool_name), + ('cutter_spacing_code', '=', self.cutter_spacing_code) + ]).write({ + 'tool_name': self.tool_name, + 'tool_brand': self.tool_brand, + 'tool_type': self.tool_type, + 'knife_handle_name': self.knife_handle_name, + 'knife_handle_brand': self.knife_handle_brand, + 'knife_handle_type': self.knife_handle_type, + 'coarse_middle_thin': self.coarse_middle_thin, + 'tool_loading_length': self.tool_loading_length, + 'new_former': self.new_former, + 'reference_length': self.reference_length, + 'cut_time': self.cut_time, + 'cut_length': self.cut_length, + 'cut_number': self.cut_number, + 'assemble_status': '1', + 'tool_loading_person': self.env.user.name, + 'tool_loading_time': fields.Datetime.now() + }) + + # 关闭弹出窗口 + return {'type': 'ir.actions.act_window_close'} +class DeliveryOfCargoFromStorage(models.TransientModel): + _name = 'sf.delivery.of.cargo.from.storage' + _description = '出库' + functional_tool_code = fields.Char(string='功能刀具编码') + functional_tool_name = fields.Char(string='功能刀具名称') + functional_tool_type = fields.Char(string='功能刀具类型') + production_line_name = fields.Char(string='产线名称') + machine_tool_code = fields.Char(string='机台号') + receive_person = fields.Char(string='领用人') + receive_time = fields.Datetime(string='领用出库时间') - - - + def stock_removal(self): + """ + 出库 + :return: + """ \ No newline at end of file diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml index 4706f86e..14303edb 100644 --- a/sf_tool_management/wizard/wizard_view.xml +++ b/sf_tool_management/wizard/wizard_view.xml @@ -177,4 +177,119 @@ new + + + ++ + +功能刀具组装单 +sf.functional.tool.assembly.order ++ + ++ + + + + +功能刀具组装单 +ir.actions.act_window +sf.functional.tool.assembly.order +form ++ new ++ + +出库 +sf.delivery.of.cargo.from.storage ++ ++ ++ + + + + + + + 出库 +ir.actions.act_window +sf.delivery.of.cargo.from.storage +tree ++ new +
+ 设备故障日志 +
+Add a new maintenance request -
+
+Follow the process of the request and communicate with the collaborator.