From 6be903305e57ce7bccc8692eee0116e25ffa215f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?=
<9664676+pengyuthon@user.noreply.gitee.com>
Date: Sat, 27 Dec 2025 17:05:16 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../views/soong_workflow_record.xml | 4 +-
.../models/inherit_purchase_order.py | 36 ++++++++-
.../views/inherit_purchase_order_views.xml | 73 ++++---------------
3 files changed, 50 insertions(+), 63 deletions(-)
diff --git a/soong_workflow/views/soong_workflow_record.xml b/soong_workflow/views/soong_workflow_record.xml
index 3f04bee28..d4f712fe0 100644
--- a/soong_workflow/views/soong_workflow_record.xml
+++ b/soong_workflow/views/soong_workflow_record.xml
@@ -92,7 +92,7 @@
+ groups="soong_workflow.group_soong_workflow_manager"/>
+ invisible="approve_state != 'start'"/>
diff --git a/yuthon_purchase/models/inherit_purchase_order.py b/yuthon_purchase/models/inherit_purchase_order.py
index 6caf4fcf4..0207023f9 100644
--- a/yuthon_purchase/models/inherit_purchase_order.py
+++ b/yuthon_purchase/models/inherit_purchase_order.py
@@ -27,14 +27,11 @@ class InheritPurchaseOrder(models.Model):
document_ids = fields.Many2many('ir.attachment', string="附件")
start_date = fields.Date(string="申请日期", default=fields.Date.today())
purchase_type = fields.Selection(
- [('fixed', '固定资产'), ('low', '低值易耗'), ('service', '服务'), ('day', '日常消耗品')],
+ [('fixed', '固定资产'), ('low', '低值易耗'), ('service', '服务'), ('book', '书籍报刊'), ('foot', '饭堂食材')],
string="采购类型", default='fixed')
pay_way = fields.Selection([('onetime', '一次性'), ('installment', '分期')], string="付款方式", default='onetime')
reason_text = fields.Text(string="申请事由")
pay_line_ids = fields.One2many('purchase.order.pay.line', 'order_id', string="付款详情")
- low_line_ids = fields.One2many('purchase.low.line', 'order_id', string="低值易耗明细")
- service_line_ids = fields.One2many('purchase.service.line', 'order_id', string="服务明细")
- fixed_line_ids = fields.One2many('purchase.fixed.line', 'order_id', string="日常消耗品明细")
def update_state(self):
order_ids = self.env["purchase.order"].browse(
@@ -96,3 +93,34 @@ class InheritPurchaseOrder(models.Model):
if self.user_id == self.env.user:
raise UserError("您不能接收自己创建的采购订单产品")
return super(InheritPurchaseOrder, self).action_view_picking()
+
+
+class InheritPurchaseOrderLine(models.Model):
+ _inherit = 'purchase.order.line'
+
+ purchase_type = fields.Selection(
+ [('fixed', '固定资产'), ('low', '低值易耗'), ('service', '服务'), ('book', '书籍报刊'), ('foot', '饭堂食材')],
+ string="采购类型", default='fixed')
+ category_ids = fields.Many2many('product.category', string="产品分类", compute='_compute_purchase_type')
+
+ @api.depends('purchase_type')
+ def _compute_purchase_type(self):
+ for record in self:
+ PURCHASE_TYPE_MAP = {
+ 'fixed': '固定资产',
+ 'low': '低值易耗',
+ 'book': '书籍报刊',
+ 'foot': '饭堂食材'
+ }
+ matching_categories = self.env['product.category']
+ target_category_name = PURCHASE_TYPE_MAP.get(record.purchase_type)
+ if target_category_name:
+ matching_categories = self.env['product.category'].search([
+ '|',
+ ('name', '=', target_category_name),
+ '|',
+ ('parent_id.name', '=', target_category_name),
+ ('parent_id.parent_id.name', '=', target_category_name),
+ ])
+ record.category_ids = [(6, 0, matching_categories.ids)] if matching_categories else [(5,)]
+
diff --git a/yuthon_purchase/views/inherit_purchase_order_views.xml b/yuthon_purchase/views/inherit_purchase_order_views.xml
index 0a7550854..7bc53b322 100644
--- a/yuthon_purchase/views/inherit_purchase_order_views.xml
+++ b/yuthon_purchase/views/inherit_purchase_order_views.xml
@@ -85,71 +85,30 @@
[('is_employee', '=', False)]
+
+ [('categ_id', 'in', category_ids)]
+
- purchase_type != 'fixed'
- 固定资产明细
+
+
+
+
+
+
+ {'default_purchase_type': purchase_type}
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
True