From 916f7bc3b24aecbc6a972e8d801bd18d89f6feb1 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, 13 Dec 2025 18:28:17 +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
---
yuthon_purchase/models/purchase_workflow.py | 2 ++
.../views/purchase_workflow_views.xml | 1 +
yuthon_stock/models/inherit_stock_picking.py | 24 +++++++++++++++----
yuthon_stock/views/inherit_stock_picking.xml | 10 +++++---
4 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/yuthon_purchase/models/purchase_workflow.py b/yuthon_purchase/models/purchase_workflow.py
index fd9f9a507..a75507a7a 100644
--- a/yuthon_purchase/models/purchase_workflow.py
+++ b/yuthon_purchase/models/purchase_workflow.py
@@ -28,6 +28,7 @@ class PurchaseWorkflow(models.Model):
document_ids = fields.Many2many('ir.attachment', string="附件")
active = fields.Boolean('启用', default=True, tracking=True)
work_end = fields.Boolean(string="审批结束", default=False, tracking=True)
+ purchase_order_id = fields.Many2one('purchase.order', string="采购订单", readonly=True)
purchase_type = fields.Selection([('fixed', '固定资产'), ('low', '低值易耗'), ('service', '服务')],
string="采购类型", required=True, default='fixed')
@@ -65,6 +66,7 @@ class PurchaseWorkflow(models.Model):
'company_id': rec.company_id.id,
'user_id': rec.user_id.id,
})
+ rec.purchase_order_id = purchase_order.id
order_lines = []
if rec.purchase_type == 'fixed':
for line in rec.fixed_line_ids:
diff --git a/yuthon_purchase/views/purchase_workflow_views.xml b/yuthon_purchase/views/purchase_workflow_views.xml
index d632c22c2..f7b3b9aec 100644
--- a/yuthon_purchase/views/purchase_workflow_views.xml
+++ b/yuthon_purchase/views/purchase_workflow_views.xml
@@ -57,6 +57,7 @@
+
diff --git a/yuthon_stock/models/inherit_stock_picking.py b/yuthon_stock/models/inherit_stock_picking.py
index 22bcc9afd..6eeebb2cf 100644
--- a/yuthon_stock/models/inherit_stock_picking.py
+++ b/yuthon_stock/models/inherit_stock_picking.py
@@ -17,13 +17,29 @@ class StockPicking(models.Model):
store=True
)
- @api.onchange('employee_id')
- def _onchange_employee_id(self):
- if self.employee_id:
- self.department_id = self.employee_id.department_id.id
+ @api.onchange('user_id')
+ def _onchange_user_id(self):
+ if self.user_id:
+ self.department_id = self.user_id.employee_ids.department_id.id
else:
self.department_id = False
+ @api.constrains("department_id")
+ def _check_department_id(self):
+ if self.department_id:
+ location_dest_id = self.env['stock.location'].search([('name', '=', self.department_id.name)], limit=1)
+ if not location_dest_id:
+ company_id = self.user_id.company_id
+ location_id = self.env['stock.location'].search([('complete_name', '=', company_id.name)])
+ location_dest_id = self.env['stock.location'].create({
+ 'name': self.department_id.name,
+ 'location_id': location_id.id,
+ 'complete_name': company_id.name,
+ 'usage': 'internal',
+ 'company_id': company_id.id,
+ })
+ self.location_dest_id = location_dest_id
+
@api.depends(
'move_ids_without_package.product_id',
'move_ids_without_package.product_uom_qty',
diff --git a/yuthon_stock/views/inherit_stock_picking.xml b/yuthon_stock/views/inherit_stock_picking.xml
index 9e55b0f0b..329e3fd60 100644
--- a/yuthon_stock/views/inherit_stock_picking.xml
+++ b/yuthon_stock/views/inherit_stock_picking.xml
@@ -13,15 +13,18 @@
-
+
-
- 确认入库
+
+ 确认入库
+
+
+ 确认入库
1
@@ -50,6 +53,7 @@
目的位置
+ 1
供应商