diff --git a/sf_base/__manifest__.py b/sf_base/__manifest__.py index 0640922a..bcb25c81 100644 --- a/sf_base/__manifest__.py +++ b/sf_base/__manifest__.py @@ -18,7 +18,6 @@ 'views/common_view.xml', 'views/fixture_view.xml', 'views/functional_fixture_view.xml', - # 'views/quick_easy_order_view.xml', 'views/menu_view.xml', "views/tool_views.xml", "views/tool_menu.xml", diff --git a/sf_base/models/__init__.py b/sf_base/models/__init__.py index 20bf8c6b..483787eb 100644 --- a/sf_base/models/__init__.py +++ b/sf_base/models/__init__.py @@ -3,7 +3,7 @@ from . import common from . import tool_base_new from . import fixture from . import functional_fixture -# from . import quick_easy_order + diff --git a/sf_base/models/fixture.py b/sf_base/models/fixture.py index 727f58bc..bbaecb7c 100644 --- a/sf_base/models/fixture.py +++ b/sf_base/models/fixture.py @@ -26,7 +26,6 @@ class FixtureModel(models.Model): _name = 'sf.fixture.model' _description = "夹具型号" - code = fields.Char(string='编码') name = fields.Char(string="名称", size=15) fixture_material_id = fields.Many2one('sf.fixture.material', string="夹具物料", ) fixture_material_type = fields.Char(string="夹具物料类型", related='fixture_material_id.name', store=True) @@ -53,10 +52,38 @@ class FixtureModel(models.Model): screw_size = fields.Integer(string="螺牙大小[mm]", size=6) active = fields.Boolean('有效', default=True) - # @api.model - # def create(self, vals): - # obj = super(FixtureModel, self).create(vals) - # return obj + def _get_code(self, fixture_model_type_code): + fixture_model = self.env['sf.fixture.model'].sudo().search( + [('code', 'ilike', fixture_model_type_code)], + limit=1, + order="id desc") + if not fixture_model: + num = "%03d" % 1 + else: + m = int(fixture_model.code[-3:]) + 1 + num = "%03d" % m + return "%s%s" % (fixture_model_type_code, num) + code = fields.Char(string='编码', readonly=True) + def _onchange_fixture_material_id(self, fixture_material_id): + if fixture_material_id: + if fixture_material_id.name == "气动夹具": + code = self._get_code("JKM-C-JJWL-QDJJ-") + elif fixture_material_id.name == "转接板(锁板)夹具": + code = self._get_code("JKM-C-JJWL-ZJBJJ-") + elif fixture_material_id.name == "磁吸夹具": + code = self._get_code("JKM-C-JJWL-CXJJ-") + elif fixture_material_id.name == "虎钳夹具": + code = self._get_code("JKM-C-JJWL-HQJJ-") + else: + code = self._get_code("JKM-C-JJWL-LDKP-") + return code + @api.model + def create(self, vals): + obj = super(FixtureModel, self).create(vals) + if obj.fixture_material_id: + code = self._onchange_fixture_material_id(obj.fixture_material_id) + obj.code = code + return obj diff --git a/sf_base/models/quick_easy_order.py b/sf_base/models/quick_easy_order.py deleted file mode 100644 index c39b3fc5..00000000 --- a/sf_base/models/quick_easy_order.py +++ /dev/null @@ -1,26 +0,0 @@ -from odoo import models, fields -import datetime -import base64 - - -class QuickEasyOrder(models.Model): - _name = 'quick.easy.order' - _description = '简易下单' - - name = fields.Char('订单编号', default=lambda self: self.env['ir.sequence'].next_by_code('quick.easy.order')) - machining_precision = fields.Selection([ - ('0.10', '±0.10mm'), - ('0.05', '±0.05mm'), - ('0.03', '±0.03mm'), - ('0.02', '±0.02mm'), - ('0.01', '±0.01mm')], string='加工精度') - material_id = fields.Many2one('sf.production.materials', '材料') - material_model_id = fields.Many2one('sf.materials.model', '型号') - process_id = fields.Many2one('sf.production.process', string='表面工艺') - parameter_ids = fields.One2many('sf.production.process.parameter', 'process_id', string='可选参数') - quantity = fields.Integer('数量') - price = fields.Float('总价') - model_file = fields.Binary('模型文件') - upload_model_file = fields.Many2many('ir.attachment', 'upload_qf_model_file_attachment_ref', string='上传模型文件') - delivery_time = fields.Date('交货日期') - customer_id = fields.Many2one('res.partner', string='客户', default=lambda self: self.env.user.partner_id.id) diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py index 575afd5f..2891da17 100644 --- a/sf_base/models/tool_base_new.py +++ b/sf_base/models/tool_base_new.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- from odoo import fields, models, api + + # from datetime import datetime # from odoo.exceptions import ValidationError @@ -95,7 +97,6 @@ class CuttingToolModel(models.Model): _description = '刀具型号' name = fields.Char('名称') - code = fields.Char('编码') cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', string='刀具物料') cutting_tool_type = fields.Char(string="刀具物料类型", related='cutting_tool_material_id.name', store=True) cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='刀具类型', @@ -177,12 +178,43 @@ class CuttingToolModel(models.Model): ) active = fields.Boolean('有效', default=True) - # @api.model - # def create(self, vals): - # if vals.get('name', '/') == '/' or vals.get('name', '/') is False: - # vals['name'] = '/' - # obj = super(CuttingToolModel, self).create(vals) - # return obj + def _get_code(self, cutting_tool_type_code): + cutting_tool_model = self.search( + [('code', 'ilike', cutting_tool_type_code)], + limit=1, + order="id desc") + if not cutting_tool_model: + num = "%03d" % 1 + else: + m = int(cutting_tool_model.code[-3:]) + 1 + num = "%03d" % m + return "%s%s" % (cutting_tool_type_code, num) + + code = fields.Char(string='编码', readonly=True) + + def _onchange_cutting_tool_material_id(self, cutting_tool_material_id): + if cutting_tool_material_id: + if cutting_tool_material_id.name == "整体式刀具": + code = self._get_code("JKM-T-DJWL-ZTDJ-") + elif cutting_tool_material_id.name == "刀片": + code = self._get_code("JKM-T-DJWL-DPIA-") + elif cutting_tool_material_id.name == "刀杆": + code = self._get_code("JKM-T-DJWL-DGAN-") + elif cutting_tool_material_id.name == "刀盘": + code = self._get_code("JKM-T-DJWL-DPAN-") + elif cutting_tool_material_id.name == "夹头": + code = self._get_code("JKM-T-DJWL-DJIA-") + else: + code = self._get_code("JKM-T-DJWL-DBIN-") + return code + + @api.model + def create(self, vals): + obj = super(CuttingToolModel, self).create(vals) + if obj.cutting_tool_material_id: + code = self._onchange_cutting_tool_material_id(obj.cutting_tool_material_id) + obj.code = code + return obj # 刀具类型 diff --git a/sf_base/views/fixture_view.xml b/sf_base/views/fixture_view.xml index e363b039..487899eb 100644 --- a/sf_base/views/fixture_view.xml +++ b/sf_base/views/fixture_view.xml @@ -163,7 +163,7 @@ 夹具型号 sf.fixture.model - + @@ -177,11 +177,11 @@ 夹具型号 sf.fixture.model -
+

- +

@@ -229,7 +229,8 @@ attrs='{"invisible": [("fixture_material_type","!=",("转接板(锁板)夹具"))]}'/> - diff --git a/sf_base/views/menu_fixture_view.xml b/sf_base/views/menu_fixture_view.xml index 7186fe35..81cb4c27 100644 --- a/sf_base/views/menu_fixture_view.xml +++ b/sf_base/views/menu_fixture_view.xml @@ -32,10 +32,10 @@ name="功能夹具类型" sequence="3" /> - + + + sequence="4" /> \ No newline at end of file diff --git a/sf_base/views/quick_easy_order_view.xml b/sf_base/views/quick_easy_order_view.xml deleted file mode 100644 index 5126afb1..00000000 --- a/sf_base/views/quick_easy_order_view.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - 快速订单编码规则 - quick.easy.order - FP-%(year)s-%(month)s%(day)s- - 4 - - - # ---------- 快速订单 ------------ - - - tree.quick.easy.order - quick.easy.order - - - - - - - - - - - - - - - - form.quick.easy.order - quick.easy.order - - - - - - - - - - search.quick.easy.order - quick.easy.order - - - - - - - - - - - 快速订单 - quick.easy.order - tree,form - [] - {} - -

- [便捷订单] 还没有哦!点左上角的[创建]按钮,沙发归你了! -

-

-

-
-
- - - - - - -
-
\ No newline at end of file diff --git a/sf_base/views/tool_base_menu.xml b/sf_base/views/tool_base_menu.xml index aef0c124..6bd12d74 100644 --- a/sf_base/views/tool_base_menu.xml +++ b/sf_base/views/tool_base_menu.xml @@ -109,13 +109,13 @@ - + + + + + + + - + + + + + + + product.template
- + + + + +