未齐套提示
This commit is contained in:
@@ -362,7 +362,8 @@ class sf_production_plan(models.Model):
|
||||
def _compute_hide_action_purchase_orders(self):
|
||||
for record in self:
|
||||
record.hide_action_purchase_orders = False
|
||||
if record.material_check == '0' and not record.sale_order_line_id.is_incoming_material:
|
||||
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)
|
||||
@@ -379,13 +380,30 @@ class sf_production_plan(models.Model):
|
||||
if line.product_id in raw_materials
|
||||
)
|
||||
record.hide_action_purchase_orders = total_purchase_quantity < record.product_uom_qty and pr_ids.state != 'done'
|
||||
elif record.supply_method == 'purchase':
|
||||
purchase_orders = self.env['purchase.order'].sudo().search([
|
||||
('state', 'in', ('purchase', 'done')),
|
||||
('order_line.product_id', '=', record.product_id.id)
|
||||
])
|
||||
total_purchase_quantity = sum(
|
||||
line.product_qty for order in purchase_orders for line in order.order_line
|
||||
if line.product_id in record.product_id
|
||||
)
|
||||
record.hide_action_purchase_orders = total_purchase_quantity < record.product_uom_qty
|
||||
|
||||
@api.depends('sale_order_id.mrp_production_ids.picking_ids', 'sale_order_id.mrp_production_ids.picking_ids.state')
|
||||
def _compute_hide_action_stock_picking(self):
|
||||
for record in self:
|
||||
manufacturing_orders = record.sale_order_id.mrp_production_ids
|
||||
record.hide_action_stock_picking = bool(manufacturing_orders.mapped('picking_ids').filtered(
|
||||
lambda p: p.state == 'assigned'))
|
||||
record.hide_action_stock_picking = False
|
||||
if record.supply_method in ('automation', 'manual'):
|
||||
manufacturing_orders = record.sale_order_id.mrp_production_ids
|
||||
record.hide_action_stock_picking = bool(manufacturing_orders.mapped('picking_ids').filtered(
|
||||
lambda p: p.state == 'assigned'))
|
||||
elif record.supply_method == 'purchase':
|
||||
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)
|
||||
record.hide_action_stock_picking = bool(assigned_picking_ids)
|
||||
|
||||
def action_open_sale_order(self):
|
||||
self.ensure_one()
|
||||
@@ -420,9 +438,14 @@ class sf_production_plan(models.Model):
|
||||
|
||||
def action_view_purchase_request(self):
|
||||
self.ensure_one()
|
||||
first_mp = self.env['mrp.production'].search(
|
||||
[('origin', '=', self.sale_order_id.name)], limit=1, order='id asc')
|
||||
pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', first_mp.name)])
|
||||
domain = []
|
||||
if self.supply_method in ('automation', 'manual'):
|
||||
first_mp = self.env['mrp.production'].search(
|
||||
[('origin', '=', self.sale_order_id.name)], limit=1, order='id asc')
|
||||
domain = [('origin', 'like', first_mp.name)]
|
||||
elif self.supply_method == 'purchase':
|
||||
domain = [('origin', 'like', self.sale_order_id.name)]
|
||||
pr_ids = self.env['purchase.request'].sudo().search(domain)
|
||||
action = {
|
||||
'res_model': 'purchase.request',
|
||||
'type': 'ir.actions.act_window',
|
||||
@@ -443,16 +466,23 @@ class sf_production_plan(models.Model):
|
||||
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 = self.sale_order_id.mrp_production_ids.mapped('picking_ids').filtered(
|
||||
lambda p: p.state == 'assigned')
|
||||
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
|
||||
picking_ids = None
|
||||
if self.supply_method in ('automation', 'manual'):
|
||||
picking_ids = self.sale_order_id.mrp_production_ids.mapped('picking_ids').filtered(
|
||||
lambda p: p.state == 'assigned')
|
||||
elif self.supply_method == 'purchase':
|
||||
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 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()
|
||||
@@ -463,4 +493,3 @@ class sf_production_plan(models.Model):
|
||||
programming_no = list(set(programming_mrp_production_ids))
|
||||
numbers_str = "、".join(programming_no)
|
||||
raise ValidationError(f"编程单号:{numbers_str},请去云平台处理")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user