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