27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import fields, models, api
|
|
|
|
|
|
class MrpProduction(models.Model):
|
|
_inherit = 'mrp.production'
|
|
|
|
demand_plan_line_id = fields.Many2one(comodel_name="sf.production.demand.plan",
|
|
string="需求计划明细", readonly=True)
|
|
|
|
@api.depends('demand_plan_line_id')
|
|
def _compute_production_type(self):
|
|
for production in self:
|
|
if production.demand_plan_line_id.supply_method == 'automation':
|
|
production.production_type = '自动化产线加工'
|
|
elif production.demand_plan_line_id.supply_method == 'manual':
|
|
production.production_type = '人工线下加工'
|
|
else:
|
|
production.production_type = None
|
|
|
|
def _get_purchase_request(self):
|
|
"""获取跟制造订单相关的采购申请单(根据采购申请单行项目的产品匹配)"""
|
|
pr_ids = self.env['purchase.request'].sudo().search([('line_ids.demand_plan_line_id', 'in', self.demand_plan_line_id.ids)])
|
|
return pr_ids
|