36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
from odoo import models, fields, api, _
|
|
from odoo.exceptions import UserError, ValidationError
|
|
|
|
|
|
class PurchaseRequestLine(models.Model):
|
|
_inherit = 'purchase.request.line'
|
|
_description = '采购申请明细'
|
|
|
|
supply_method = fields.Selection([
|
|
('automation', "自动化产线加工"),
|
|
('manual', "人工线下加工"),
|
|
('purchase', "外购"),
|
|
('outsourcing', "委外加工"),
|
|
], string='供货方式', readonly=True)
|
|
|
|
demand_plan_line_id = fields.Many2one(comodel_name="sf.production.demand.plan",
|
|
string="需求计划明细", readonly=True)
|
|
|
|
@api.depends('demand_plan_line_id')
|
|
def _compute_supply_method(self):
|
|
for prl in self:
|
|
if prl.demand_plan_line_id:
|
|
prl.supply_method = prl.demand_plan_line_id.supply_method
|
|
else:
|
|
prl.supply_method = None
|
|
|
|
|
|
class PurchaseRequestLineMakePurchaseOrder(models.TransientModel):
|
|
_inherit = "purchase.request.line.make.purchase.order"
|
|
|
|
@api.model
|
|
def _prepare_purchase_order_line(self, po, item):
|
|
ret = super(PurchaseRequestLineMakePurchaseOrder, self)._prepare_purchase_order_line(po, item)
|
|
ret['demand_plan_line_id'] = item.line_id.demand_plan_line_id.id
|
|
return ret
|