diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 4fc7fde0..e784ea73 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -9,8 +9,6 @@ import requests from itertools import groupby from collections import defaultdict, namedtuple -from loguru import _logger - from odoo import api, fields, models, SUPERUSER_ID, _ from odoo.exceptions import UserError, ValidationError from odoo.addons.sf_base.commons.common import Common @@ -21,7 +19,7 @@ class MrpProduction(models.Model): _inherit = 'mrp.production' _description = "制造订单" _order = 'create_date desc' - sale_order_id = fields.Many2one('sale.order',string='销售订单', compute='_compute_sale_order_id', store=True) + sale_order_id = fields.Many2one('sale.order', string='销售订单', compute='_compute_sale_order_id', store=True) deadline_of_delivery = fields.Date('订单交期', tracking=True, compute='_compute_deadline_of_delivery') # tray_ids = fields.One2many('sf.tray', 'production_id', string="托盘") maintenance_count = fields.Integer(compute='_compute_maintenance_count', string="Number of maintenance requests") @@ -56,10 +54,11 @@ class MrpProduction(models.Model): if sale_order: production.sale_order_id = sale_order.id else: - _logger.warning("No sale order found for production %s with product %s (name match: %s)", - production.id, production.product_id.name, result) + logging.warning("No sale order found for production {} with product {} (name match: {})".format( + production.id, production.product_id.name, result)) except Exception as e: - _logger.error("Error while fetching sale order for production %s: %s", production.id, str(e)) + logging.error("Error while fetching sale order for production {}: {}".format(production.id, str(e))) + @api.depends('procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id') def _compute_deadline_of_delivery(self): for production in self: @@ -788,7 +787,7 @@ class MrpProduction(models.Model): # 立即创建外协出入库单和采购订单 # self.env['stock.picking'].create_outcontract_picking(workorder, production) # self.env['purchase.order'].get_purchase_order(workorder, production, - # product_id_to_production_names) + # product_id_to_production_names) consecutive_workorders = [] # 处理最后一个组,即使它可能只有一个工作订单 @@ -800,6 +799,7 @@ class MrpProduction(models.Model): for workorders in reversed(proc_workorders): self.env['stock.picking'].create_outcontract_picking(workorders, production, sorted_workorders) self.env['purchase.order'].get_purchase_order(workorders, production, product_id_to_production_names) + # 工单排序 def _reset_work_order_sequence1(self, k): for rec in self: @@ -1468,6 +1468,7 @@ class MrpProduction(models.Model): production.sale_order_count = 1 else: production.sale_order_count = 0 + def action_view_sale_orders(self): if self.sale_order_id: action = { @@ -1480,7 +1481,6 @@ class MrpProduction(models.Model): }) return action - @api.model_create_multi def create(self, vals_list): """