From 2862c5a888eecdae7aa69bf905e92c4175481cdc Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 17 Jun 2024 09:52:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=AE=A2=E6=88=B7=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=AD=97=E6=AE=B5=E5=BF=85=E5=A1=AB=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E5=92=8C=E8=BF=94=E5=B7=A5=E6=8A=A5=E5=BA=9F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 3 +- sf_manufacturing/models/mrp_production.py | 21 +++------ sf_manufacturing/models/mrp_workorder.py | 18 ++++---- sf_sale/models/sale_order.py | 12 +++--- sf_sale/views/res_partner_view.xml | 42 +++++++++--------- sf_sale/views/sale_order_view.xml | 48 --------------------- 6 files changed, 44 insertions(+), 100 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index c85a559e..ddbf4048 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -215,7 +215,8 @@ class Manufacturing_Connect(http.Controller): if workorder.state != 'progress': res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单未开始'} return json.JSONEncoder().encode(res) - workorder.write({'date_finished': datetime.now()}) + # workorder.write({'date_finished': datetime.now()}) + workorder.button_finish() # workorder.process_state = '待解除装夹' # workorder.sudo().production_id.process_state = '待解除装夹' diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 4b9de955..0f428d43 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -293,7 +293,7 @@ class MrpProduction(models.Model): # 则根据设备找到工作中心;否则采用前面描述的工作中心分配机制; # 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心; - def _create_workorder3(self, is_fetchcnc=False, scrap_production=False): + def _create_workorder3(self): # 根据product_id对self进行分组 grouped_product_ids = {k: list(g) for k, g in groupby(self, key=lambda x: x.product_id.id)} # 初始化一个字典来存储每个product_id对应的生产订单名称列表 @@ -336,12 +336,9 @@ class MrpProduction(models.Model): production_programming = self.search( [('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)], limit=1, order='id asc') - if not production_programming.programming_no or (is_fetchcnc is True and scrap_production): - # 制造订单报废/返工也需重新编程 - if (is_fetchcnc is True and scrap_production is False) or ( - is_fetchcnc is False and scrap_production is False): - production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]), - scrap_production) + if not production_programming.programming_no: + production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]), + scrap_production) else: production.write({'programming_no': production_programming.programming_no, 'programming_state': '编程中'}) @@ -409,12 +406,6 @@ class MrpProduction(models.Model): workorders_values.append( self.env['mrp.workorder'].json_workorder_str('', production, route)) production.workorder_ids = workorders_values - if production_programming.programming_state == '已编程': - logging.info("production_programming: %s" % production_programming.name) - production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').write({ - 'cnc_ids': production_programming.workorder_ids.filtered( - lambda - t1: t1.routing_type == 'CNC加工').cnc_ids}) for workorder in production.workorder_ids: workorder.duration_expected = workorder._get_duration_expected() @@ -557,8 +548,8 @@ class MrpProduction(models.Model): # work.button_finish() # 创建工单并进行排序 - def _create_workorder(self, is_fetchcnc=False, scrap_production=False): - self._create_workorder3(is_fetchcnc=is_fetchcnc, scrap_production=scrap_production) + def _create_workorder(self): + self._create_workorder3() self._reset_work_order_sequence() return True diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 7eea98da..1d65c0ae 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -996,15 +996,15 @@ class ResMrpWorkOrder(models.Model): record.write({ 'date_planned_finished': tem_date_planned_finished # 保持原值 }) - if record.routing_type == 'CNC加工': - record.write({ - 'date_finished': tem_date_finished # 保持原值 - }) - if record.routing_type == 'CNC加工' and record.test_results in ['返工', '报废']: - record.production_id.action_cancel() - record.production_id.workorder_ids.write({'rfid_code': False, 'rfid_code_old': record.rfid_code}) - if record.is_remanufacture is True: - record.recreateManufacturingOrWorkerOrder() + # if record.routing_type == 'CNC加工': + # record.write({ + # 'date_finished': tem_date_finished # 保持原值 + # }) + # if record.routing_type == 'CNC加工' and record.test_results in ['返工', '报废']: + # record.production_id.action_cancel() + # record.production_id.workorder_ids.write({'rfid_code': False, 'rfid_code_old': record.rfid_code}) + # if record.is_remanufacture is True: + # record.recreateManufacturingOrWorkerOrder() is_production_id = True for workorder in record.production_id.workorder_ids: if workorder.state != 'done': diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index e168292b..9486f73c 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -233,12 +233,12 @@ class ResPartnerToSale(models.Model): if obj: raise UserError('该税ID已存在,请重新输入') - @api.constrains('email') - def _check_email(self): - if self.customer_rank > 0: - obj = self.sudo().search([('email', '=', self.email), ('id', '!=', self.id), ('active', '=', True)]) - if obj: - raise UserError('该邮箱已存在,请重新输入') + # @api.constrains('email') + # def _check_email(self): + # if self.customer_rank > 0: + # obj = self.sudo().search([('email', '=', self.email), ('id', '!=', self.id), ('active', '=', True)]) + # if obj: + # raise UserError('该邮箱已存在,请重新输入') @api.model def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None): diff --git a/sf_sale/views/res_partner_view.xml b/sf_sale/views/res_partner_view.xml index cc8f49fb..a680bd7c 100644 --- a/sf_sale/views/res_partner_view.xml +++ b/sf_sale/views/res_partner_view.xml @@ -24,18 +24,18 @@ 1 {'readonly': [('id','!=', False)]} - - - - - {'required': [('phone', '=', False)],'readonly': [('id','!=', False)]} - - - - {'required': [('mobile', '=', False)],'readonly': [('id','!=', False)]} - - + + + + + + + + + + + + {'readonly': [('id','!=', False)]} @@ -56,10 +56,10 @@ - - 1 - {'readonly': [('id','!=', False)]} - + + + + {'readonly': [('id','!=', False)]} @@ -101,7 +101,7 @@ + attrs="{'required' : [('supplier_rank','>', 0)]}"/> {'readonly': [('id','!=', False)]} @@ -195,10 +195,10 @@ {'invisible': [('customer_rank','=', 0)]} - - - + + + + diff --git a/sf_sale/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml index 0981ff59..647cf8ef 100644 --- a/sf_sale/views/sale_order_view.xml +++ b/sf_sale/views/sale_order_view.xml @@ -1,54 +1,6 @@ - - sale.order.search.inherit.sf - sale.order - primary - - - - - - - - - - - - - - - 报价 - ir.actions.act_window - sale.order - - tree,kanban,form,calendar,pivot,graph,activity - - {'search_default_my_quotation': 1} - -

- Create a new quotation, the first step of a new sale! -

-

- Once the quotation is confirmed by the customer, it becomes a sales order. -
- You will be able to create an invoice and collect the payment. -

-
-
- - - - - - - - sale.order.form.inherit.sf sale.order