需求计划详情调拨单显示

This commit is contained in:
guanhuan
2025-07-18 15:33:51 +08:00
parent 19417dd569
commit cdb3cc7c03
7 changed files with 123 additions and 11 deletions

View File

@@ -10,3 +10,4 @@ from . import stock_rule
from . import purchase_request
from . import purchase_order
from . import stock_move
from . import stock_picking

View File

@@ -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,
}}

View File

@@ -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