diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py
index 83b4c800..556a6d98 100644
--- a/sf_demand_plan/models/sf_production_demand_plan.py
+++ b/sf_demand_plan/models/sf_production_demand_plan.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
+from odoo.tools import float_compare
class sf_production_plan(models.Model):
@@ -215,16 +216,18 @@ class sf_production_plan(models.Model):
record.actual_end_date = None
@api.depends('sale_order_id.mrp_production_ids.move_raw_ids.forecast_availability',
- 'sale_order_id.mrp_production_ids.move_raw_ids.product_uom_qty')
+ 'sale_order_id.mrp_production_ids.move_raw_ids.quantity_done')
def _compute_material_check(self):
for record in self:
if record.sale_order_id and record.sale_order_id.mrp_production_ids:
manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered(
lambda mo: mo.product_id == record.product_id)
- if manufacturing_orders:
- total_reserved = sum(mo.forecast_availability for mo in manufacturing_orders)
- total_to_consume = sum(mo.product_uom_qty for mo in manufacturing_orders)
- if total_reserved >= total_to_consume:
+ if manufacturing_orders and manufacturing_orders.move_raw_ids:
+ total_forecast_availability = sum(manufacturing_orders.mapped('move_raw_ids.forecast_availability'))
+ total_quantity_done = sum(manufacturing_orders.mapped('move_raw_ids.quantity_done'))
+ total_sum = total_forecast_availability + total_quantity_done
+ if float_compare(total_sum, record.product_uom_qty,
+ precision_rounding=record.product_id.uom_id.rounding) >= 0:
record.material_check = '1' # 已齐套
else:
record.material_check = '0' # 未齐套
@@ -238,3 +241,6 @@ class sf_production_plan(models.Model):
for record in self:
if record.planned_start_date and record.planned_start_date < fields.Date.today():
raise ValidationError("计划开工日期必须大于或等于今天。")
+
+ def release_production_order(self):
+ pass
diff --git a/sf_demand_plan/views/demand_plan.xml b/sf_demand_plan/views/demand_plan.xml
index 9c9ee0ce..94d81fea 100644
--- a/sf_demand_plan/views/demand_plan.xml
+++ b/sf_demand_plan/views/demand_plan.xml
@@ -43,6 +43,8 @@
+