23 lines
956 B
Python
23 lines
956 B
Python
from odoo import api, fields, models, _
|
|
from odoo.tools import float_compare
|
|
|
|
|
|
class PurchaseOrder(models.Model):
|
|
_inherit = 'purchase.order'
|
|
|
|
demand_plan_line_id = fields.Many2one(comodel_name="sf.production.demand.plan",
|
|
string="需求计划明细", readonly=True)
|
|
|
|
@api.depends('origin', 'demand_plan_line_id')
|
|
def _compute_purchase_type(self):
|
|
for purchase in self:
|
|
if purchase.order_line[0].product_id.categ_id.name == '坯料':
|
|
if purchase.order_line[0].product_id.materials_type_id.gain_way == '外协':
|
|
purchase.purchase_type = 'outsourcing'
|
|
else:
|
|
if purchase.demand_plan_line_id.supply_method == 'outsourcing':
|
|
purchase.purchase_type = 'outsourcing'
|
|
|
|
elif purchase.demand_plan_line_id.supply_method == 'purchase':
|
|
purchase.purchase_type = 'outside'
|