提交7249和7246需求
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
from odoo.tools import float_compare
|
from odoo.tools import float_compare
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class SfDemandPlan(models.Model):
|
class SfDemandPlan(models.Model):
|
||||||
@@ -10,8 +11,7 @@ class SfDemandPlan(models.Model):
|
|||||||
_description = 'sf_demand_plan'
|
_description = 'sf_demand_plan'
|
||||||
|
|
||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
('10', '需求确认'),
|
('10', '待工艺设计'),
|
||||||
('20', '待工艺设计'),
|
|
||||||
('30', '部分下达'),
|
('30', '部分下达'),
|
||||||
('40', '已下达'),
|
('40', '已下达'),
|
||||||
('50', '取消'),
|
('50', '取消'),
|
||||||
@@ -83,6 +83,8 @@ class SfDemandPlan(models.Model):
|
|||||||
compute='_compute_readonly_custom_made_type',
|
compute='_compute_readonly_custom_made_type',
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
demand_plan_number = fields.Char('需求计划号', compute='_compute_demand_plan_number', readonly=True, store=True)
|
||||||
|
origin = fields.Char('来源', related='sale_order_id.name', readonly=True, store=True)
|
||||||
|
|
||||||
@api.depends('product_id.part_number', 'product_id.model_name')
|
@api.depends('product_id.part_number', 'product_id.model_name')
|
||||||
def _compute_part_number(self):
|
def _compute_part_number(self):
|
||||||
@@ -210,3 +212,17 @@ class SfDemandPlan(models.Model):
|
|||||||
else:
|
else:
|
||||||
for demand_plan_line_id in line_ids:
|
for demand_plan_line_id in line_ids:
|
||||||
demand_plan_line_id.action_confirm()
|
demand_plan_line_id.action_confirm()
|
||||||
|
#需求要求取值格式是来源+来源明细行ID,但是来源明细行ID取得就是product_id.name得最后一位,所以这里也直接截取product_id.name
|
||||||
|
@api.depends('product_id.name')
|
||||||
|
def _compute_demand_plan_number(self):
|
||||||
|
for line in self:
|
||||||
|
product_name = line.product_id.name or ''
|
||||||
|
plan_no = None
|
||||||
|
if line.product_id:
|
||||||
|
# 使用正则表达式匹配P-后面的所有字符
|
||||||
|
match = re.search(r'P-(.*)', product_name)
|
||||||
|
if match:
|
||||||
|
plan_no = match.group(1)
|
||||||
|
line.demand_plan_number = plan_no
|
||||||
|
else:
|
||||||
|
line.demand_plan_number = None
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
<sheet>
|
<sheet>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
|
<field name="demand_plan_number"/>
|
||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
<field name="part_name"/>
|
<field name="part_name"/>
|
||||||
<field name="part_number"/>
|
<field name="part_number"/>
|
||||||
@@ -35,6 +36,7 @@
|
|||||||
<field name="model_machining_precision"/>
|
<field name="model_machining_precision"/>
|
||||||
<field name="inventory_quantity_auto_apply"/>
|
<field name="inventory_quantity_auto_apply"/>
|
||||||
<field name="priority" attrs="{'readonly': [('state', 'in', ('40','50'))]}"/>
|
<field name="priority" attrs="{'readonly': [('state', 'in', ('40','50'))]}"/>
|
||||||
|
<field name="origin"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
|
|||||||
Reference in New Issue
Block a user