diff --git a/sf_demand_plan/__manifest__.py b/sf_demand_plan/__manifest__.py index 932685e0..2a543f1a 100644 --- a/sf_demand_plan/__manifest__.py +++ b/sf_demand_plan/__manifest__.py @@ -23,6 +23,7 @@ ], 'web.assets_backend': [ 'sf_demand_plan/static/src/scss/style.css', + 'sf_demand_plan/static/src/js/print_demand.js', ] }, 'license': 'LGPL-3', diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py index ef11adcc..c0121d58 100644 --- a/sf_demand_plan/models/sf_production_demand_plan.py +++ b/sf_demand_plan/models/sf_production_demand_plan.py @@ -272,18 +272,15 @@ class SfProductionDemandPlan(models.Model): else: 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.quantity_done') + @api.depends('sale_order_id.mrp_production_ids.move_raw_ids.reserved_availability') 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 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, + total_reserved_availability = sum(manufacturing_orders.mapped('move_raw_ids.reserved_availability')) + if float_compare(total_reserved_availability, record.product_uom_qty, precision_rounding=record.product_id.uom_id.rounding) >= 0: record.material_check = '1' # 已齐套 else: @@ -323,6 +320,7 @@ class SfProductionDemandPlan(models.Model): 'name': _("打印"), 'domain': [('demand_plan_id', 'in', self.ids)], 'views': [[self.env.ref('sf_demand_plan.action_plan_print_tree').id, 'list']], + 'search_view_id': self.env.ref('sf_demand_plan.action_plan_print_search').id, 'target': 'new', } @@ -503,7 +501,10 @@ class SfProductionDemandPlan(models.Model): action = self.env["ir.actions.actions"]._for_xml_id("stock.action_picking_tree_all") picking_ids = None if self.supply_method in ('automation', 'manual'): - picking_ids = self.sale_order_id.mrp_production_ids.mapped('picking_ids').filtered( + 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( diff --git a/sf_demand_plan/static/src/js/print_demand.js b/sf_demand_plan/static/src/js/print_demand.js new file mode 100644 index 00000000..6dacc7b3 --- /dev/null +++ b/sf_demand_plan/static/src/js/print_demand.js @@ -0,0 +1,215 @@ +odoo.define('sf_demand.print_demand', function (require) { + "use strict"; + + var ListController = require('web.ListController'); + var ListRenderer = require('web.ListRenderer'); + var ListView = require('web.ListView'); + var viewRegistry = require('web.view_registry'); + var { url } = require("@web/core/utils/urls") + + var CustomListRenderer = ListRenderer.extend({ + _render: function () { + var self = this; + this.getParent()?.$buttons.hide(); + + return this._super.apply(this, arguments).then(function () { + // 添加图片预览容器到页面左侧 + if (!$('.table-image-preview-container').length) { + self.$el.parent().addClass('custom-table-image-container') + self.$el.before( + `
+ +