From cdb3cc7c03619975a0b2b010e08621b9d034acc7 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Fri, 18 Jul 2025 15:33:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E8=AE=A1=E5=88=92=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E8=B0=83=E6=8B=A8=E5=8D=95=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_demand_plan/models/__init__.py | 1 + .../models/sf_production_demand_plan.py | 39 +++++++++++----- sf_demand_plan/models/stock_picking.py | 16 +++++++ sf_demand_plan/views/demand_plan.xml | 4 ++ .../wizard/sf_demand_plan_detail_wizard.py | 45 +++++++++++++++++++ .../sf_demand_plan_detail_wizard_view.xml | 27 +++++++++++ .../wizard/sf_demand_plan_print_wizard.py | 2 +- 7 files changed, 123 insertions(+), 11 deletions(-) create mode 100644 sf_demand_plan/models/stock_picking.py diff --git a/sf_demand_plan/models/__init__.py b/sf_demand_plan/models/__init__.py index 46c426fd..e911ac92 100644 --- a/sf_demand_plan/models/__init__.py +++ b/sf_demand_plan/models/__init__.py @@ -10,3 +10,4 @@ from . import stock_rule from . import purchase_request from . import purchase_order from . import stock_move +from . import stock_picking diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py index f85adc65..1841fbee 100644 --- a/sf_demand_plan/models/sf_production_demand_plan.py +++ b/sf_demand_plan/models/sf_production_demand_plan.py @@ -911,22 +911,14 @@ class SfProductionDemandPlan(models.Model): } return values - @api.model - def check_other_custom_made_demands(self, plan_id, product_id, custom_made_type): - return bool(self.env['sf.production.demand.plan'].sudo().search_count([ - ('product_id', '=', product_id), - ('id', '!=', plan_id), - ('new_supply_method', '=', 'custom_made'), - ('status', '=', '30'), - ('custom_made_type', '!=', custom_made_type), - ], limit=1)) - def button_plan_detail(self): self.ensure_one() purchase_request_ids = self.env['purchase.request'].sudo().search( [('line_ids.demand_plan_line_id', 'in', self.ids)]) purchase_order_ids = self.env['purchase.order'].sudo().search( [('order_line.demand_plan_line_id', 'in', self.ids)]) + picking_ids = self.env['stock.picking'].sudo().search( + [('demand_plan_line_ids', 'in', self.ids)]) return { 'name': _('详情'), 'type': 'ir.actions.act_window', @@ -949,4 +941,31 @@ class SfProductionDemandPlan(models.Model): 'default_outside_purchase_order_ids': purchase_order_ids.filtered( lambda o: o.purchase_type == 'outside' ).ids, + 'default_in_stock_picking_ids': picking_ids.filtered( + lambda o: o.picking_type_sequence_code == 'IN' + ).ids, + 'default_dl_stock_picking_ids': picking_ids.filtered( + lambda o: o.picking_type_sequence_code == 'DL' + ).ids, + 'default_int_stock_picking_ids': picking_ids.filtered( + lambda o: o.picking_type_sequence_code == 'INT' + ).ids, + 'default_pc_stock_picking_ids': picking_ids.filtered( + lambda o: o.picking_type_sequence_code == 'PC' + ).ids, + 'default_sfp_stock_picking_ids': picking_ids.filtered( + lambda o: o.picking_type_sequence_code == 'SFP' + ).ids, + 'default_onin_stock_picking_ids': picking_ids.filtered( + lambda o: o.picking_type_sequence_code == 'OCIN' + ).ids, + 'default_ocout_stock_picking_ids': picking_ids.filtered( + lambda o: o.picking_type_sequence_code == 'OCOUT' + ).ids, + 'default_out_stock_picking_ids': picking_ids.filtered( + lambda o: o.picking_type_sequence_code == 'OUT' + ).ids, + 'default_res_stock_picking_ids': picking_ids.filtered( + lambda o: o.picking_type_sequence_code == 'RES' + ).ids, }} diff --git a/sf_demand_plan/models/stock_picking.py b/sf_demand_plan/models/stock_picking.py new file mode 100644 index 00000000..8a1a1abd --- /dev/null +++ b/sf_demand_plan/models/stock_picking.py @@ -0,0 +1,16 @@ +from odoo import fields, api, models, _ + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + demand_plan_line_ids = fields.Many2many(comodel_name="sf.production.demand.plan", + string="需求计划明细", compute='_compute_demand_plan_line_ids', store=True) + + @api.depends('move_ids_without_package') + def _compute_demand_plan_line_ids(self): + for line in self: + demand_plan_lines = self.env['sf.production.demand.plan'] + if line.move_ids_without_package and line.move_ids_without_package.demand_plan_line_ids: + demand_plan_lines |= line.move_ids_without_package.demand_plan_line_ids + line.demand_plan_line_ids = demand_plan_lines.ids diff --git a/sf_demand_plan/views/demand_plan.xml b/sf_demand_plan/views/demand_plan.xml index a5b3bddd..9bc631ad 100644 --- a/sf_demand_plan/views/demand_plan.xml +++ b/sf_demand_plan/views/demand_plan.xml @@ -92,6 +92,10 @@ attrs="{'invisible': [('hide_release_production_order', '=', False)]}" />