From c31cc868a9f32e3ccd28b0afb354a2b828340379 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 30 Jun 2025 17:10:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E6=96=99=E9=9C=80=E6=B1=82=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_demand_plan/__manifest__.py | 1 + sf_demand_plan/models/mrp_production.py | 5 + .../models/sf_production_demand_plan.py | 499 +++++++++--------- sf_demand_plan/models/sf_production_plan.py | 15 + sf_demand_plan/views/demand_plan.xml | 43 +- sf_demand_plan/views/demand_plan_info.xml | 5 + sf_demand_plan/views/menu_view.xml | 18 + 7 files changed, 325 insertions(+), 261 deletions(-) create mode 100644 sf_demand_plan/models/sf_production_plan.py create mode 100644 sf_demand_plan/views/menu_view.xml diff --git a/sf_demand_plan/__manifest__.py b/sf_demand_plan/__manifest__.py index 4327514a..474c1608 100644 --- a/sf_demand_plan/__manifest__.py +++ b/sf_demand_plan/__manifest__.py @@ -20,6 +20,7 @@ 'views/sale_order_views.xml', 'wizard/sf_demand_plan_print_wizard_view.xml', 'wizard/sf_release_plan_wizard_views.xml', + 'views/menu_view.xml', ], 'demo': [ ], diff --git a/sf_demand_plan/models/mrp_production.py b/sf_demand_plan/models/mrp_production.py index 4eb1bc05..4a618cea 100644 --- a/sf_demand_plan/models/mrp_production.py +++ b/sf_demand_plan/models/mrp_production.py @@ -19,3 +19,8 @@ class MrpProduction(models.Model): production.production_type = '人工线下加工' else: production.production_type = None + + def _get_purchase_request(self): + """获取跟制造订单相关的采购申请单""" + pr_ids = self.env['purchase.request'].sudo().search([('origin', '=', self.name)]) + return pr_ids diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py index da1c2bd3..bf27d5ee 100644 --- a/sf_demand_plan/models/sf_production_demand_plan.py +++ b/sf_demand_plan/models/sf_production_demand_plan.py @@ -108,37 +108,49 @@ class SfProductionDemandPlan(models.Model): print_count = fields.Char('打印次数', default='T0C0', readonly=True) sequence = fields.Integer('序号') - hide_action_open_mrp_production = fields.Boolean( - string='显示待工艺确认按钮', - compute='_compute_hid_button', + mrp_production_ids = fields.Many2many( + 'mrp.production', + compute='_compute_mrp_production_ids', + string='与此相需求计划关联的制造订单', + store=True) + + hide_release_production_order = fields.Boolean( + string='显示下发生产按钮', + compute='_compute_hide_release_production_order', default=False ) - hide_action_purchase_orders = fields.Boolean( - string='显示采购按钮', - compute='_compute_hide_action_purchase_orders', - default=False - ) - - hide_action_stock_picking = fields.Boolean( - string='显示调拨单按钮', - compute='_compute_hide_action_stock_picking', - default=False - ) - - hide_action_outsourcing_stock_picking = fields.Boolean( - string='委外显示调拨单按钮', - compute='_compute_hide_action_stock_picking', - default=False - ) - - hide_action_view_programming = fields.Boolean( - string='显示编程单按钮', - compute='_compute_hid_button', - default=False - ) - - outsourcing_purchase_request = fields.Char('委外采购申请单') + # hide_action_open_mrp_production = fields.Boolean( + # string='显示待工艺确认按钮', + # compute='_compute_hid_button', + # default=False + # ) + # + # hide_action_purchase_orders = fields.Boolean( + # string='显示采购按钮', + # compute='_compute_hide_action_purchase_orders', + # default=False + # ) + # + # hide_action_stock_picking = fields.Boolean( + # string='显示调拨单按钮', + # compute='_compute_hide_action_stock_picking', + # default=False + # ) + # + # hide_action_outsourcing_stock_picking = fields.Boolean( + # string='委外显示调拨单按钮', + # compute='_compute_hide_action_stock_picking', + # default=False + # ) + # + # hide_action_view_programming = fields.Boolean( + # string='显示编程单按钮', + # compute='_compute_hid_button', + # default=False + # ) + # + # outsourcing_purchase_request = fields.Char('委外采购申请单') plan_uom_qty = fields.Float(string="计划量") procurement_reason = fields.Selection([ @@ -242,6 +254,20 @@ class SfProductionDemandPlan(models.Model): else: record.material_check = None + @api.depends('status') + def _compute_mrp_production_ids(self): + for record in self: + record.mrp_production_ids = self.env['mrp.production'].sudo().search( + [('demand_plan_line_id', '=', record.id)]).ids + + @api.depends('mrp_production_ids.state') + def _compute_hide_release_production_order(self): + for record in self: + # 检查这条需求计划所有制造订单的排程单状态,有一个为待排程状态,就显示改按钮 + record.hide_release_production_order = bool(record.mrp_production_ids.filtered( + lambda p: p.state == 'confirmed' + )) + @api.constrains('planned_start_date') def _check_planned_start_date(self): for record in self: @@ -252,7 +278,7 @@ class SfProductionDemandPlan(models.Model): if not self.planned_start_date: raise ValidationError("请先填写计划开工日期") pro_plan_list = self.env['sf.production.plan'].search( - [('product_id', '=', self.product_id.id), ('state', '=', 'draft')]) + [('production_id', 'in', self.mrp_production_ids.ids), ('state', '=', 'draft')]) sf_production_line = self.env['sf.production.line'].sudo().search( [('name', '=', '1#CNC自动生产线')], limit=1) if sf_production_line: @@ -263,6 +289,11 @@ class SfProductionDemandPlan(models.Model): pro_plan_list.production_line_id = sf_production_line.id pro_plan_list.date_planned_start = date_planned_start self._do_production_schedule(pro_plan_list) + self.status = '60' + + def _do_production_schedule(self, pro_plan_list): + for pro_plan in pro_plan_list: + pro_plan.do_production_schedule() def edit_button(self): self.ensure_one() @@ -278,10 +309,6 @@ class SfProductionDemandPlan(models.Model): action.update({'flags': {'mode': 'readonly'}}) return action - def _do_production_schedule(self, pro_plan_list): - for pro_plan in pro_plan_list: - pro_plan.do_production_schedule() - def button_action_print(self): return { 'res_model': 'sf.demand.plan.print.wizard', @@ -292,214 +319,214 @@ class SfProductionDemandPlan(models.Model): 'target': 'new', } - @api.depends('sale_order_id.mrp_production_ids.state', 'sale_order_id.mrp_production_ids.programming_state') - def _compute_hid_button(self): - for record in self: - mrp_production_ids = record.sale_order_id.mrp_production_ids.filtered( - lambda p: p.state == 'technology_to_confirmed' and p.product_id.id == record.product_id.id - ) - record.hide_action_open_mrp_production = bool(mrp_production_ids) and record.supply_method in ( - 'automation', 'manual') - programming_mrp_production_ids = record.sale_order_id.mrp_production_ids.filtered( - lambda p: p.programming_state == '编程中' and p.product_id.id == record.product_id.id - ) - record.hide_action_view_programming = bool(programming_mrp_production_ids) + # @api.depends('sale_order_id.mrp_production_ids.state', 'sale_order_id.mrp_production_ids.programming_state') + # def _compute_hid_button(self): + # for record in self: + # mrp_production_ids = record.sale_order_id.mrp_production_ids.filtered( + # lambda p: p.state == 'technology_to_confirmed' and p.product_id.id == record.product_id.id + # ) + # record.hide_action_open_mrp_production = bool(mrp_production_ids) and record.supply_method in ( + # 'automation', 'manual') + # programming_mrp_production_ids = record.sale_order_id.mrp_production_ids.filtered( + # lambda p: p.programming_state == '编程中' and p.product_id.id == record.product_id.id + # ) + # record.hide_action_view_programming = bool(programming_mrp_production_ids) + # + # def _compute_hide_action_purchase_orders(self): + # for record in self: + # record.hide_action_purchase_orders = False + # outsourcing_purchase_request = [] + # if record.supply_method in ('automation', + # 'manual') and record.material_check == '0' and not record.sale_order_line_id.is_incoming_material: + # mrp_production = record.sale_order_id.mrp_production_ids.filtered( + # lambda p: p.product_id.id == record.product_id.id + # ).sorted(key=lambda p: p.id) + # if mrp_production: + # raw_materials = mrp_production.mapped('move_raw_ids.product_id') + # if raw_materials: + # purchase_orders = self.env['purchase.order'].sudo().search([ + # ('state', '=', 'purchase'), + # ('order_line.product_id', 'in', raw_materials.ids) + # ]) + # total_purchase_quantity = sum( + # sum( + # order.order_line.filtered( + # lambda line: line.product_id in raw_materials + # ).mapped('product_qty') + # ) + # for order in purchase_orders + # ) + # if float_compare(total_purchase_quantity, record.product_uom_qty, + # precision_rounding=record.product_id.uom_id.rounding) == -1: + # pr_ids = self.env['purchase.request'].sudo().search( + # [('line_ids.product_id', 'in', raw_materials.ids), ('state', '!=', 'done')]) + # outsourcing_purchase_request.extend(pr_ids.ids) + # elif record.supply_method in ('purchase', 'outsourcing'): + # purchase_orders = self.env['purchase.order'].sudo().search([ + # ('state', 'in', ('purchase', 'done')), + # ('order_line.product_id', '=', record.product_id.id) + # ]) + # total_purchase_quantity = sum( + # sum( + # order.order_line.filtered( + # lambda line: line.product_id in record.product_id + # ).mapped('product_qty') + # ) + # for order in purchase_orders + # ) + # + # if float_compare(total_purchase_quantity, record.product_uom_qty, + # precision_rounding=record.product_id.uom_id.rounding) == -1: + # pr_ids = self.env['purchase.request'].sudo().search( + # [('origin', 'like', record.sale_order_id.name), ('state', '!=', 'done')]) + # outsourcing_purchase_request.extend(pr_ids.ids) + # if record.supply_method == 'outsourcing' and not record.sale_order_line_id.is_incoming_material: + # bom_line_ids = record.product_id.bom_ids.bom_line_ids + # if bom_line_ids: + # # BOM_数量 + # total_product_qty = sum(line.product_qty for line in bom_line_ids) + # bom_product_ids = bom_line_ids.mapped('product_id') + # product_purchase_orders = self.env['purchase.order'].sudo().search([ + # ('state', 'in', ('purchase', 'done')), + # ('order_line.product_id', 'in', bom_product_ids.ids) + # ]) + # # 购订单_数量 + # total_outsourcing_purchase_quantity = sum( + # sum( + # order.order_line.filtered( + # lambda line: line.product_id in bom_product_ids + # ).mapped('product_qty') + # ) + # for order in product_purchase_orders + # ) + # quantity = total_outsourcing_purchase_quantity / total_product_qty + # if float_compare(quantity, record.product_uom_qty, + # precision_rounding=record.product_id.uom_id.rounding) == -1: + # purchase_request = self.env['purchase.request'].sudo().search( + # [('line_ids.product_id', 'in', bom_product_ids.ids), + # ('line_ids.purchase_state', 'not in', ('purchase', 'done')), ('state', '!=', 'done')]) + # outsourcing_purchase_request.extend(purchase_request.ids) + # record.outsourcing_purchase_request = json.dumps(outsourcing_purchase_request) + # if outsourcing_purchase_request: + # record.hide_action_purchase_orders = True + # + # @api.depends('sale_order_id.mrp_production_ids.picking_ids.state', 'sale_order_id.picking_ids.state') + # def _compute_hide_action_stock_picking(self): + # for record in self: + # record.hide_action_stock_picking = False + # record.hide_action_outsourcing_stock_picking = False + # if record.supply_method in ('automation', 'manual'): + # manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered( + # lambda p: p.product_id.id == record.product_id.id + # ) + # record.hide_action_stock_picking = bool(manufacturing_orders.mapped('picking_ids').filtered( + # lambda p: p.state == 'assigned')) + # elif record.supply_method in ('purchase', 'outsourcing'): + # assigned_picking_ids = record.sale_order_id.picking_ids.filtered( + # lambda + # p: p.state == 'assigned' and p.picking_type_id.name != '发料出库' and p.move_line_ids.product_id in record.product_id) + # if record.supply_method == 'outsourcing': + # outsourcing_assigned_picking_ids = record.get_outsourcing_picking_ids() + # record.hide_action_outsourcing_stock_picking = outsourcing_assigned_picking_ids + # record.hide_action_stock_picking = assigned_picking_ids or outsourcing_assigned_picking_ids + # else: + # record.hide_action_stock_picking = assigned_picking_ids + # + # def get_outsourcing_picking_ids(self): + # order_ids = self.env['purchase.order'].sudo().search( + # [('order_line.product_id', 'in', self.product_id.ids), + # ('purchase_type', '=', 'outsourcing')]) + # outsourcing_picking_ids = order_ids._get_subcontracting_resupplies() + # outsourcing_assigned_picking_ids = outsourcing_picking_ids.filtered(lambda p: p.state == 'assigned') + # return outsourcing_assigned_picking_ids - def _compute_hide_action_purchase_orders(self): - for record in self: - record.hide_action_purchase_orders = False - outsourcing_purchase_request = [] - if record.supply_method in ('automation', - 'manual') and record.material_check == '0' and not record.sale_order_line_id.is_incoming_material: - mrp_production = record.sale_order_id.mrp_production_ids.filtered( - lambda p: p.product_id.id == record.product_id.id - ).sorted(key=lambda p: p.id) - if mrp_production: - raw_materials = mrp_production.mapped('move_raw_ids.product_id') - if raw_materials: - purchase_orders = self.env['purchase.order'].sudo().search([ - ('state', '=', 'purchase'), - ('order_line.product_id', 'in', raw_materials.ids) - ]) - total_purchase_quantity = sum( - sum( - order.order_line.filtered( - lambda line: line.product_id in raw_materials - ).mapped('product_qty') - ) - for order in purchase_orders - ) - if float_compare(total_purchase_quantity, record.product_uom_qty, - precision_rounding=record.product_id.uom_id.rounding) == -1: - pr_ids = self.env['purchase.request'].sudo().search( - [('line_ids.product_id', 'in', raw_materials.ids), ('state', '!=', 'done')]) - outsourcing_purchase_request.extend(pr_ids.ids) - elif record.supply_method in ('purchase', 'outsourcing'): - purchase_orders = self.env['purchase.order'].sudo().search([ - ('state', 'in', ('purchase', 'done')), - ('order_line.product_id', '=', record.product_id.id) - ]) - total_purchase_quantity = sum( - sum( - order.order_line.filtered( - lambda line: line.product_id in record.product_id - ).mapped('product_qty') - ) - for order in purchase_orders - ) + # def action_open_sale_order(self): + # self.ensure_one() + # return { + # 'type': 'ir.actions.act_window', + # 'res_model': 'sale.order', + # 'res_id': self.sale_order_id.id, + # 'view_mode': 'form', + # } - if float_compare(total_purchase_quantity, record.product_uom_qty, - precision_rounding=record.product_id.uom_id.rounding) == -1: - pr_ids = self.env['purchase.request'].sudo().search( - [('origin', 'like', record.sale_order_id.name), ('state', '!=', 'done')]) - outsourcing_purchase_request.extend(pr_ids.ids) - if record.supply_method == 'outsourcing' and not record.sale_order_line_id.is_incoming_material: - bom_line_ids = record.product_id.bom_ids.bom_line_ids - if bom_line_ids: - # BOM_数量 - total_product_qty = sum(line.product_qty for line in bom_line_ids) - bom_product_ids = bom_line_ids.mapped('product_id') - product_purchase_orders = self.env['purchase.order'].sudo().search([ - ('state', 'in', ('purchase', 'done')), - ('order_line.product_id', 'in', bom_product_ids.ids) - ]) - # 购订单_数量 - total_outsourcing_purchase_quantity = sum( - sum( - order.order_line.filtered( - lambda line: line.product_id in bom_product_ids - ).mapped('product_qty') - ) - for order in product_purchase_orders - ) - quantity = total_outsourcing_purchase_quantity / total_product_qty - if float_compare(quantity, record.product_uom_qty, - precision_rounding=record.product_id.uom_id.rounding) == -1: - purchase_request = self.env['purchase.request'].sudo().search( - [('line_ids.product_id', 'in', bom_product_ids.ids), - ('line_ids.purchase_state', 'not in', ('purchase', 'done')), ('state', '!=', 'done')]) - outsourcing_purchase_request.extend(purchase_request.ids) - record.outsourcing_purchase_request = json.dumps(outsourcing_purchase_request) - if outsourcing_purchase_request: - record.hide_action_purchase_orders = True + # def action_open_mrp_production(self): + # self.ensure_one() + # mrp_production_ids = self.sale_order_id.mrp_production_ids.filtered( + # lambda p: p.state == 'technology_to_confirmed' and p.product_id.id == self.product_id.id + # ) + # action = { + # 'res_model': 'mrp.production', + # 'type': 'ir.actions.act_window', + # } + # if len(mrp_production_ids) == 1: + # action.update({ + # 'view_mode': 'form', + # 'res_id': mrp_production_ids.id, + # }) + # else: + # action.update({ + # 'name': _("制造订单列表"), + # 'domain': [('id', 'in', mrp_production_ids.ids)], + # 'view_mode': 'tree,form', + # }) + # return action - @api.depends('sale_order_id.mrp_production_ids.picking_ids.state', 'sale_order_id.picking_ids.state') - def _compute_hide_action_stock_picking(self): - for record in self: - record.hide_action_stock_picking = False - record.hide_action_outsourcing_stock_picking = False - if record.supply_method in ('automation', 'manual'): - manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered( - lambda p: p.product_id.id == record.product_id.id - ) - record.hide_action_stock_picking = bool(manufacturing_orders.mapped('picking_ids').filtered( - lambda p: p.state == 'assigned')) - elif record.supply_method in ('purchase', 'outsourcing'): - assigned_picking_ids = record.sale_order_id.picking_ids.filtered( - lambda - p: p.state == 'assigned' and p.picking_type_id.name != '发料出库' and p.move_line_ids.product_id in record.product_id) - if record.supply_method == 'outsourcing': - outsourcing_assigned_picking_ids = record.get_outsourcing_picking_ids() - record.hide_action_outsourcing_stock_picking = outsourcing_assigned_picking_ids - record.hide_action_stock_picking = assigned_picking_ids or outsourcing_assigned_picking_ids - else: - record.hide_action_stock_picking = assigned_picking_ids + # def action_view_purchase_request(self): + # self.ensure_one() + # pr_ids = self.env['purchase.request'].sudo().search( + # [('id', 'in', ast.literal_eval(self.outsourcing_purchase_request))]) + # action = { + # 'res_model': 'purchase.request', + # 'type': 'ir.actions.act_window', + # } + # if len(pr_ids) == 1: + # action.update({ + # 'view_mode': 'form', + # 'res_id': pr_ids[0].id, + # }) + # else: + # action.update({ + # 'name': _("采购申请"), + # 'domain': [('id', 'in', pr_ids.ids)], + # 'view_mode': 'tree,form', + # }) + # return action - def get_outsourcing_picking_ids(self): - order_ids = self.env['purchase.order'].sudo().search( - [('order_line.product_id', 'in', self.product_id.ids), - ('purchase_type', '=', 'outsourcing')]) - outsourcing_picking_ids = order_ids._get_subcontracting_resupplies() - outsourcing_assigned_picking_ids = outsourcing_picking_ids.filtered(lambda p: p.state == 'assigned') - return outsourcing_assigned_picking_ids + # def action_view_stock_picking(self): + # self.ensure_one() + # action = self.env["ir.actions.actions"]._for_xml_id("stock.action_picking_tree_all") + # picking_ids = None + # if self.supply_method in ('automation', 'manual'): + # mrp_production_ids = self.sale_order_id.mrp_production_ids.filtered( + # lambda p: p.product_id.id == self.product_id.id + # ) + # picking_ids = mrp_production_ids.mapped('picking_ids').filtered( + # lambda p: p.state == 'assigned') + # elif self.supply_method in ('purchase', 'outsourcing'): + # picking_ids = self.sale_order_id.picking_ids.filtered( + # lambda + # p: p.state == 'assigned' and p.picking_type_id.name != '发料出库' and p.move_line_ids.product_id in self.product_id) + # if self.supply_method == 'outsourcing' and self.hide_action_outsourcing_stock_picking: + # picking_ids = picking_ids.union(self.get_outsourcing_picking_ids()) + # if picking_ids: + # if len(picking_ids) > 1: + # action['domain'] = [('id', 'in', picking_ids.ids)] + # elif picking_ids: + # action['res_id'] = picking_ids.id + # action['views'] = [(self.env.ref('stock.view_picking_form').id, 'form')] + # if 'views' in action: + # action['views'] += [(state, view) for state, view in action['views'] if view != 'form'] + # return action - def action_open_sale_order(self): - self.ensure_one() - return { - 'type': 'ir.actions.act_window', - 'res_model': 'sale.order', - 'res_id': self.sale_order_id.id, - 'view_mode': 'form', - } - - def action_open_mrp_production(self): - self.ensure_one() - mrp_production_ids = self.sale_order_id.mrp_production_ids.filtered( - lambda p: p.state == 'technology_to_confirmed' and p.product_id.id == self.product_id.id - ) - action = { - 'res_model': 'mrp.production', - 'type': 'ir.actions.act_window', - } - if len(mrp_production_ids) == 1: - action.update({ - 'view_mode': 'form', - 'res_id': mrp_production_ids.id, - }) - else: - action.update({ - 'name': _("制造订单列表"), - 'domain': [('id', 'in', mrp_production_ids.ids)], - 'view_mode': 'tree,form', - }) - return action - - def action_view_purchase_request(self): - self.ensure_one() - pr_ids = self.env['purchase.request'].sudo().search( - [('id', 'in', ast.literal_eval(self.outsourcing_purchase_request))]) - action = { - 'res_model': 'purchase.request', - 'type': 'ir.actions.act_window', - } - if len(pr_ids) == 1: - action.update({ - 'view_mode': 'form', - 'res_id': pr_ids[0].id, - }) - else: - action.update({ - 'name': _("采购申请"), - 'domain': [('id', 'in', pr_ids.ids)], - 'view_mode': 'tree,form', - }) - return action - - def action_view_stock_picking(self): - self.ensure_one() - action = self.env["ir.actions.actions"]._for_xml_id("stock.action_picking_tree_all") - picking_ids = None - if self.supply_method in ('automation', 'manual'): - mrp_production_ids = self.sale_order_id.mrp_production_ids.filtered( - lambda p: p.product_id.id == self.product_id.id - ) - picking_ids = mrp_production_ids.mapped('picking_ids').filtered( - lambda p: p.state == 'assigned') - elif self.supply_method in ('purchase', 'outsourcing'): - picking_ids = self.sale_order_id.picking_ids.filtered( - lambda - p: p.state == 'assigned' and p.picking_type_id.name != '发料出库' and p.move_line_ids.product_id in self.product_id) - if self.supply_method == 'outsourcing' and self.hide_action_outsourcing_stock_picking: - picking_ids = picking_ids.union(self.get_outsourcing_picking_ids()) - if picking_ids: - if len(picking_ids) > 1: - action['domain'] = [('id', 'in', picking_ids.ids)] - elif picking_ids: - action['res_id'] = picking_ids.id - action['views'] = [(self.env.ref('stock.view_picking_form').id, 'form')] - if 'views' in action: - action['views'] += [(state, view) for state, view in action['views'] if view != 'form'] - return action - - def action_view_programming(self): - self.ensure_one() - programming_mrp_production_ids = self.sale_order_id.mrp_production_ids.filtered( - lambda p: p.programming_state == '编程中' and p.product_id.id == self.product_id.id - ).mapped('programming_no') - if programming_mrp_production_ids: - programming_no = list(set(programming_mrp_production_ids)) - numbers_str = "、".join(programming_no) - raise ValidationError(f"编程单号:{numbers_str},请去云平台处理") + # def action_view_programming(self): + # self.ensure_one() + # programming_mrp_production_ids = self.sale_order_id.mrp_production_ids.filtered( + # lambda p: p.programming_state == '编程中' and p.product_id.id == self.product_id.id + # ).mapped('programming_no') + # if programming_mrp_production_ids: + # programming_no = list(set(programming_mrp_production_ids)) + # numbers_str = "、".join(programming_no) + # raise ValidationError(f"编程单号:{numbers_str},请去云平台处理") def button_delete(self): self.ensure_one() diff --git a/sf_demand_plan/models/sf_production_plan.py b/sf_demand_plan/models/sf_production_plan.py new file mode 100644 index 00000000..daf527f6 --- /dev/null +++ b/sf_demand_plan/models/sf_production_plan.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +from odoo import models, fields, api, _ + + +class SfProductionPlan(models.Model): + _inherit = 'sf.production.plan' + + demand_plan_line_id = fields.Many2one(comodel_name="sf.production.demand.plan", + string="需求计划明细", readonly=True) + + @api.model + def create(self, vals): + res = super(SfProductionPlan, self).create(vals) + res.demand_plan_line_id = res.production_id.demand_plan_line_id.id + return res diff --git a/sf_demand_plan/views/demand_plan.xml b/sf_demand_plan/views/demand_plan.xml index 062fe9ea..dc8a99c9 100644 --- a/sf_demand_plan/views/demand_plan.xml +++ b/sf_demand_plan/views/demand_plan.xml @@ -46,20 +46,20 @@ - - - - -