新增坯料类型
This commit is contained in:
@@ -7,3 +7,4 @@ from . import stock_route
|
||||
from . import mrp_bom
|
||||
from . import mrp_production
|
||||
from . import stock_rule
|
||||
from . import purchase_request
|
||||
|
||||
24
sf_demand_plan/models/purchase_request.py
Normal file
24
sf_demand_plan/models/purchase_request.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from odoo import models, fields, api, _
|
||||
|
||||
|
||||
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
|
||||
@@ -10,12 +10,15 @@ class ReSaleOrder(models.Model):
|
||||
string='与此销售订单相关联的制造订单',
|
||||
groups='mrp.group_mrp_user', store=True)
|
||||
|
||||
demand_plan_id = fields.Many2one(comodel_name="sf.demand.plan",
|
||||
string="需求计划", readonly=True)
|
||||
|
||||
demand_plan_count = fields.Integer(
|
||||
"需求计划生成计数",
|
||||
compute='_compute_demand_plan_count',
|
||||
)
|
||||
|
||||
@api.depends('procurement_group_id')
|
||||
@api.depends('demand_plan_id.line_ids.status')
|
||||
def _compute_purchase_request_count(self):
|
||||
for so in self:
|
||||
pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', so.name)])
|
||||
@@ -24,6 +27,7 @@ class ReSaleOrder(models.Model):
|
||||
else:
|
||||
so.purchase_request_purchase_order_count = 0
|
||||
|
||||
@api.depends('demand_plan_id.line_ids')
|
||||
def _compute_demand_plan_count(self):
|
||||
for line in self:
|
||||
demand_plan = self.env['sf.production.demand.plan'].sudo().search([('sale_order_id', '=', line.id)])
|
||||
@@ -48,6 +52,7 @@ class ReSaleOrder(models.Model):
|
||||
'type': '1',
|
||||
}
|
||||
self.env['sf.demand.plan.print.wizard'].sudo().create(wizard_vals)
|
||||
ret.order_id.demand_plan_id = demand_plan_info.id
|
||||
return ret
|
||||
|
||||
def confirm_to_supply_method(self):
|
||||
|
||||
@@ -15,7 +15,7 @@ class SfDemandPlan(models.Model):
|
||||
return list
|
||||
|
||||
state = fields.Selection([
|
||||
('10', '草稿'),
|
||||
('10', '需求确认'),
|
||||
('20', '待工艺设计'),
|
||||
('30', '部分下达'),
|
||||
('40', '已下达'),
|
||||
|
||||
@@ -544,9 +544,9 @@ class SfProductionDemandPlan(models.Model):
|
||||
if line_ids:
|
||||
self.bom_id = line_ids[0].bom_id.id
|
||||
return
|
||||
else:
|
||||
elif self.supply_method == 'outsourcing':
|
||||
line_ids = self.demand_plan_id.line_ids.filtered(
|
||||
lambda p: p.supply_method in ('purchase', 'outsourcing') and p.status == '60')
|
||||
lambda p: p.supply_method == 'outsourcing' and p.status == '60')
|
||||
if line_ids:
|
||||
self.bom_id = line_ids[0].bom_id.id
|
||||
return
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class StockRule(models.Model):
|
||||
@@ -14,3 +13,10 @@ class StockRule(models.Model):
|
||||
if self.env.context.get('demand_plan_line_id'):
|
||||
res['demand_plan_line_id'] = self.env.context.get('demand_plan_line_id')
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _prepare_purchase_request_line(self, request_id, procurement):
|
||||
res = super()._prepare_purchase_request_line(request_id, procurement)
|
||||
if self.env.context.get('demand_plan_line_id'):
|
||||
res['demand_plan_line_id'] = self.env.context.get('demand_plan_line_id')
|
||||
return res
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<field name="actual_start_date"/>
|
||||
<field name="actual_end_date"/>
|
||||
<field name="plan_remark"/>
|
||||
<field name="procurement_reason" widget="radio"/>
|
||||
<field name="procurement_reason"/>
|
||||
<field name="write_date" string="更新时间"/>
|
||||
<button string="下达计划" name="button_release_plan" type="object"
|
||||
class="btn-primary"
|
||||
|
||||
Reference in New Issue
Block a user