提交7249和7246需求

This commit is contained in:
chenye
2025-07-10 17:44:10 +08:00
parent 3be1c4c529
commit 2a7e07b4c0
2 changed files with 20 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
from odoo import models, fields, api, _
from odoo.tools import float_compare
from odoo.exceptions import ValidationError
import re
class SfDemandPlan(models.Model):
@@ -10,8 +11,7 @@ class SfDemandPlan(models.Model):
_description = 'sf_demand_plan'
state = fields.Selection([
('10', '需求确认'),
('20', '待工艺设计'),
('10', '待工艺设计'),
('30', '部分下达'),
('40', '已下达'),
('50', '取消'),
@@ -83,6 +83,8 @@ class SfDemandPlan(models.Model):
compute='_compute_readonly_custom_made_type',
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')
def _compute_part_number(self):
@@ -210,3 +212,17 @@ class SfDemandPlan(models.Model):
else:
for demand_plan_line_id in line_ids:
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

View File

@@ -14,6 +14,7 @@
<sheet>
<group>
<group>
<field name="demand_plan_number"/>
<field name="product_id"/>
<field name="part_name"/>
<field name="part_number"/>
@@ -35,6 +36,7 @@
<field name="model_machining_precision"/>
<field name="inventory_quantity_auto_apply"/>
<field name="priority" attrs="{'readonly': [('state', 'in', ('40','50'))]}"/>
<field name="origin"/>
</group>
</group>
<notebook>