Files
test/mrp_mps/models/purchase_order.py
qihao.gong@jikimo.com 1533ef7be9 新增主生产计划模块
2023-08-15 10:36:04 +08:00

24 lines
954 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'
date_planned_mps = fields.Datetime(string='Scheduled Date', compute='_compute_date_planned_mps', store=True, index=True)
@api.depends('order_line.date_planned', 'date_order')
def _compute_date_planned_mps(self):
for order in self:
min_date = False
for line in order.order_line:
if not min_date or line.date_planned and line.date_planned < min_date:
min_date = line.date_planned
# since we only care about the date, remove time part so that when search based on a date we can also match it
if min_date:
order.date_planned_mps = min_date.date()
else:
order.date_planned_mps = order.date_order.date()