From 6fed64ba2a3e4e2227d5f6f688d43452d7e47378 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 22 Nov 2023 17:55:30 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E8=AE=A1=E5=88=92=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/stock.py | 2 +- sf_plan/__manifest__.py | 1 + sf_plan/security/ir.model.access.csv | 9 ++------- sf_plan/security/rules.xml | 9 +++++++++ sf_plan/views/view.xml | 9 +++++---- 5 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 sf_plan/security/rules.xml diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 1722886e..baae91e1 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -199,7 +199,7 @@ class StockRule(models.Model): sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)]) if sale_order: bb = sale_order.deadline_of_delivery - productions = self.env['sf.production.plan'].with_user(SUPERUSER_ID).sudo().with_company(company_id). \ + productions = self.env['sf.production.plan'].sudo().with_company(company_id). \ create({ 'name': production.name, 'order_deadline': sale_order.deadline_of_delivery, diff --git a/sf_plan/__manifest__.py b/sf_plan/__manifest__.py index 40b36882..d0cd7bcb 100644 --- a/sf_plan/__manifest__.py +++ b/sf_plan/__manifest__.py @@ -16,6 +16,7 @@ 'depends': ['sf_manufacturing'], 'data': [ 'security/ir.model.access.csv', + # 'security/rules.xml', 'views/view.xml', ], diff --git a/sf_plan/security/ir.model.access.csv b/sf_plan/security/ir.model.access.csv index 3a1a20c9..3123afe9 100644 --- a/sf_plan/security/ir.model.access.csv +++ b/sf_plan/security/ir.model.access.csv @@ -1,8 +1,3 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_sf_production_plan,sf.production.plan,model_sf_production_plan,base.group_user,1,1,1,1 -access_sf_machine_schedule,sf.machine.schedule,model_sf_machine_schedule,base.group_user,1,1,1,1 - - - - - +access_sf_production_plan,sf.production.plan,model_sf_production_plan,base.group_user,1,0,0,0 +access_sf_production_plan_for_dispatch,sf.production.plan for dispatch,model_sf_production_plan,sf_base.group_plan_dispatch,1,1,1,0 diff --git a/sf_plan/security/rules.xml b/sf_plan/security/rules.xml new file mode 100644 index 00000000..7355bc8c --- /dev/null +++ b/sf_plan/security/rules.xml @@ -0,0 +1,9 @@ + + + Own Orders Only + + + + [('create_uid', '=', user.id)] + + \ No newline at end of file diff --git a/sf_plan/views/view.xml b/sf_plan/views/view.xml index 5df9e8db..c2faf029 100644 --- a/sf_plan/views/view.xml +++ b/sf_plan/views/view.xml @@ -18,8 +18,8 @@ - +

@@ -264,126 +274,95 @@ - + - 功能刀具实时分布 + 功能刀具安全库存 sf.real.time.distribution.of.functional.tools - - - - - - - - - - + + + + - - - - - - + + + + - 功能刀具实时分布 + 功能刀具安全库存 sf.real.time.distribution.of.functional.tools

- +

- - - - - - - - - - + + + + + - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
@@ -392,28 +371,31 @@ - 功能刀具实时分布 + 功能刀具安全库存 sf.real.time.distribution.of.functional.tools - - - - - - - - - + + + + + + + + + + + + - + - 功能刀具实时分布 + 功能刀具安全库存 ir.actions.act_window sf.real.time.distribution.of.functional.tools tree,form,search diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index d667ba33..16ae5259 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -57,12 +57,10 @@ class ToolChangeRequirementInformation(models.TransientModel): 确认换刀申请(按键) :return: """ - print('已运行') record = self.env['sf.machine.table.tool.changing.apply'].search( [('maintenance_equipment_id', '=', self.maintenance_equipment_id.id), ('cutter_spacing_code_id', '=', self.cutter_spacing_code_id.id) ]) - print('运行record_1') # 功能刀具组装创建新任务(new_assembly_task) sf_functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().create({ @@ -86,13 +84,11 @@ class ToolChangeRequirementInformation(models.TransientModel): 'reason_for_applying': self.reason_for_applying, 'sf_machine_table_tool_changing_apply_id': record.id }) - print('sf_functional_tool_assembly:', sf_functional_tool_assembly) # 修改机床换刀申请状态 record.write({ 'status': '1', - 'sf_functional_tool_assembly_id': sf_functional_tool_assembly + 'sf_functional_tool_assembly_id': sf_functional_tool_assembly.id }) - print('运行成功') # 关闭弹出窗口 return {'type': 'ir.actions.act_window_close'} @@ -186,7 +182,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 功能刀具组装信息 # 整体式刀具型号 integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号', - domain=[('product_id.cutting_tool_material_id.name', '=', '整体式刀具')]) + domain=[('product_id.cutting_tool_material_id.name', '=', '整体式刀具'), + ('quant_ids.location_id.name', 'in', ['刀具房'])]) cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', readonly=True) integral_name = fields.Char('整体式刀具名称', readonly=True) @@ -194,14 +191,16 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 刀片型号 blade_code_id = fields.Many2one('stock.lot', '刀片序列号', - domain=[('product_id.cutting_tool_material_id.name', '=', '刀片')]) + domain=[('product_id.cutting_tool_material_id.name', '=', '刀片'), + ('quant_ids.location_id.name', 'in', ['刀具房'])]) cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', readonly=True) blade_name = fields.Char('刀片名称', readonly=True) sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=True) # 刀杆型号 bar_code_id = fields.Many2one('stock.lot', '刀杆序列号', - domain=[('product_id.cutting_tool_material_id.name', '=', '刀杆')]) + domain=[('product_id.cutting_tool_material_id.name', '=', '刀杆'), + ('quant_ids.location_id.name', 'in', ['刀具房'])]) cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', readonly=True) bar_name = fields.Char('刀杆名称', readonly=True) @@ -209,7 +208,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 刀盘型号 pad_code_id = fields.Many2one('stock.lot', '刀盘序列号', - domain=[('product_id.cutting_tool_material_id.name', '=', '刀盘')]) + domain=[('product_id.cutting_tool_material_id.name', '=', '刀盘'), + ('quant_ids.location_id.name', 'in', ['刀具房'])]) cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', readonly=True) pad_name = fields.Char('刀盘名称', readonly=True) @@ -217,7 +217,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 刀柄型号 handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', required=True, - domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄')]) + domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄'), + ('quant_ids.location_id.name', 'in', ['刀具房'])]) cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', readonly=True) handle_name = fields.Char('刀柄名称', readonly=True) @@ -225,7 +226,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 夹头型号 chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', required=True, - domain=[('product_id.cutting_tool_material_id.name', '=', '夹头')]) + domain=[('product_id.cutting_tool_material_id.name', '=', '夹头'), + ('quant_ids.location_id.name', 'in', ['刀具房'])]) cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', readonly=True) chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_auto_fill') @@ -347,6 +349,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel): ]) # 对物料做必填判断 self.materials_must_be_judged() + # # 刀具物料出库 + # if self.integral_code_id: + # print("已运行1111") + # self.tool_material_out_of_store(self.integral_code_id) # 创建组装入库单 # 创建功能刀具批次/序列号记录 @@ -359,14 +365,16 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 创建功能刀具列表记录 # 封装功能刀具数据 desc_2 = self.get_desc_2(stock_lot, functional_tool_assembly) - # 创建功能刀具列表、功能刀具预警、功能刀具实时分布、功能刀具出入库记录 + # 创建功能刀具列表记录 record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2) - # self.env['sf.real.time.distribution.of.functional.tools'].create({ - # 'functional_cutting_tool_id': record_1.id - # }) - # self.env['sf.inbound.and.outbound.records.of.functional.tools'].create({ - # 'functional_cutting_tool_id': record_1.id - # }) + # 创建安全库存信息 + self.env['sf.real.time.distribution.of.functional.tools'].create_or_edit_safety_stock({ + 'name': self.after_assembly_functional_tool_name, + 'sf_cutting_tool_type_id': self.after_assembly_functional_tool_type_id.id, + 'diameter': self.after_assembly_functional_tool_diameter, + 'knife_tip_r_angle': self.after_assembly_knife_tip_r_angle, + 'coarse_middle_thin': self.after_assembly_coarse_middle_thin, + }, record_1) # 修改功能刀具组装单信息 functional_tool_assembly.write(desc_1) @@ -430,6 +438,38 @@ class FunctionalToolAssemblyOrder(models.TransientModel): return stock_lot + # def tool_material_out_of_store(self, tool_material_serial_id): + # """ + # 刀具物料出库 + # """ + # # 获取位置 + # location_id = self.env['stock.location'].search([('name', '=', 'Stock')]) + # location_dest_id = self.env['stock.location'].search([('name', '=', '刀具组装位置')]) + # print("已运行2222") + # # 创建库存移动 + # stock_move_id = self.env['stock.move'].create({ + # 'name': '刀具物料出库', + # 'lot_id': tool_material_serial_id.id, + # 'product_id': tool_material_serial_id.product_id.id, + # 'location_id': location_id.id, + # 'location_dest_id': location_dest_id.id, + # 'product_uom_qty': 1.00, + # 'state': 'done' + # }) + # print("已运行3333") + # print(stock_move_id) + # # 创建移动历史 + # stock_move_line_id = self.env['stock.move.line'].create({ + # 'product_id': tool_material_serial_id.product_id.id, + # 'lot_id': tool_material_serial_id.id, + # 'move_id': stock_move_id.id, + # 'install_tool_time': fields.Datetime.now(), + # 'qty_done': 1.0, + # 'state': 'done' + # }) + # + # return stock_move_id, stock_move_line_id + def create_stock_quant(self, product_id, stock_lot, functional_tool_assembly): """ 创建功能刀具该批次/序列号 库存移动和移动历史 From 54912f15b91f8894f25969709f27e9d6e778f6e2 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Mon, 27 Nov 2023 12:17:57 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=89=A9=E6=B5=81?= =?UTF-8?q?=E4=B8=8B=E5=8D=95=E7=AD=89=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_bf_connect/__manifest__.py | 4 +-- sf_bf_connect/models/jd_eclp.py | 13 ++++++---- sf_bf_connect/views/view.xml | 43 +++++++++++++++++---------------- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/sf_bf_connect/__manifest__.py b/sf_bf_connect/__manifest__.py index 46ca09f8..ce938272 100644 --- a/sf_bf_connect/__manifest__.py +++ b/sf_bf_connect/__manifest__.py @@ -10,10 +10,10 @@ """, 'category': 'sf', 'website': 'https://www.sf.cs.jikimo.com', - 'depends': ['sf_base'], + 'depends': ['sf_base', 'delivery'], 'data': [ 'views/res_partner_view.xml', - # 'views/view.xml', + 'views/view.xml', 'report/bill_report.xml', ], 'demo': [ diff --git a/sf_bf_connect/models/jd_eclp.py b/sf_bf_connect/models/jd_eclp.py index dfcb20f8..493e739f 100644 --- a/sf_bf_connect/models/jd_eclp.py +++ b/sf_bf_connect/models/jd_eclp.py @@ -83,6 +83,7 @@ class JdEclp(models.Model): # sale_order_id = self.env['sale.order'].search([('name', '=', self.origin)]) # if self.carrier_id == '京东物流': + config = self.env['res.config.settings'].get_values() createTime = str(datetime.now()) json1 = { 'params': { @@ -106,7 +107,7 @@ class JdEclp(models.Model): }, } _logger.info('准备调接口1') - url1 = 'https://bfm.cs.jikimo.com/api/create/jd/order' + url1 = config['bfm_url'] + '/api/create/jd/order' requests.post(url1, json=json1, data=None) _logger.info('调用成功1') _logger.info('准备调接口2') @@ -115,7 +116,7 @@ class JdEclp(models.Model): 'orderNo': self.origin, }, } - url2 = 'https://bfm.cs.jikimo.com/api/get/jd/no' + url2 = config['bfm_url'] + '/api/get/jd/no' response = requests.post(url2, json=json2, data=None) # _logger.info('调用成功2', response.json()['result']['wbNo']) self.carrier_tracking_ref = response.json()['result']['wbNo'] @@ -124,12 +125,16 @@ class JdEclp(models.Model): # raise UserError("选择京东物流才能下单呦") def get_bill(self): + """ + 获取物流面单 + """ + config = self.env['res.config.settings'].get_values() json1 = { 'params': { 'no': self.origin, }, } - url1 = 'https://bfm.cs.jikimo.com/api/create/jd/bill' + url1 = config['bfm_url'] + '/api/create/jd/bill' response = requests.post(url1, json=json1, data=None) # _logger.info('调用成功2', response.json()) @@ -152,5 +157,3 @@ class JdEclp(models.Model): # 'model_name': 'stock.picking', }) _logger.info(attachment) - # _logger.info(attachment.datas) - # _logger.info(attachment.datas_fname) diff --git a/sf_bf_connect/views/view.xml b/sf_bf_connect/views/view.xml index ec6dc394..a8236456 100644 --- a/sf_bf_connect/views/view.xml +++ b/sf_bf_connect/views/view.xml @@ -1,5 +1,18 @@ + + + 物流 + stock.picking + + + +

- - - -
-
- - - - - - + + + + + + + +
\ No newline at end of file From 96df8f971c99ea282864b9fbe558517daea3294e Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Mon, 27 Nov 2023 15:40:16 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E7=89=A9=E6=B5=81=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E5=8F=AF=E8=A7=81=E6=80=A7=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/src/list/custom_width.js | 4 +- sf_bf_connect/models/jd_eclp.py | 7 +++ sf_bf_connect/views/view.xml | 51 ++++++++++++------- 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/jikimo_frontend/static/src/list/custom_width.js b/jikimo_frontend/static/src/list/custom_width.js index 31fd23ca..785bedb5 100644 --- a/jikimo_frontend/static/src/list/custom_width.js +++ b/jikimo_frontend/static/src/list/custom_width.js @@ -66,8 +66,8 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', { // } // 判断 this.state.columns 是否存在且长度大于零 - if (this.state.columns && this.state.columns.length > 0 && - this.state.columns[0].name === "sequence") { + if (this.state.columns && this.state.columns.length > 0 + && this.state.columns[0].name === "sequence") { widths[1] = { type: "relative", value: 0.1 }; } diff --git a/sf_bf_connect/models/jd_eclp.py b/sf_bf_connect/models/jd_eclp.py index 493e739f..1b3c10ab 100644 --- a/sf_bf_connect/models/jd_eclp.py +++ b/sf_bf_connect/models/jd_eclp.py @@ -40,6 +40,13 @@ class JdEclp(models.Model): # bill = fields.Many2one('ir.attachment', string='物流面单', compute='query_bill_pdf') # bill_show = fields.Binary(string='物流面单展示', readonly=True, related='self.bill.datas') bill_show = fields.Binary(string='物流面单展示', readonly=True) + check_out = fields.Char(string='查询是否为出库单', compute='_check_is_out') + + @api.depends('name') + def _check_is_out(self): + if self.name: + is_check_out = self.name.split('/') + self.check_out = is_check_out[1] @api.depends('carrier_tracking_ref') def query_bill_pdf(self): diff --git a/sf_bf_connect/views/view.xml b/sf_bf_connect/views/view.xml index a8236456..c4f0e446 100644 --- a/sf_bf_connect/views/view.xml +++ b/sf_bf_connect/views/view.xml @@ -1,14 +1,27 @@ + + 增加一个check_out字段 + stock.picking + + + + + + + + 物流 stock.picking - -