From d7ce69f474efc3d2bb5dbf0f96465840609515bd Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Mon, 30 Dec 2024 17:04:59 +0800
Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E8=AF=A2=E4=BB=B7=E5=8D=95=E7=9A=84?=
=?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=8C=89=E9=92=AE=E6=9D=83=E9=99=90=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=EF=BC=9B2=E3=80=81=E6=88=90=E5=93=81=E8=B0=83?=
=?UTF-8?q?=E6=8B=A8=E5=8D=95=E6=B7=BB=E5=8A=A0=E5=AF=B9=E5=BA=94=E7=9A=84?=
=?UTF-8?q?=E5=9D=AF=E6=96=99=E9=87=87=E8=B4=AD=E5=8D=95=E5=92=8C=E5=9D=AF?=
=?UTF-8?q?=E6=96=99=E5=A4=96=E5=8D=8F=E5=8D=95=E8=B7=B3=E8=BD=AC=E9=93=BE?=
=?UTF-8?q?=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_sale/views/purchase_order_view.xml | 32 ++++---------
sf_stock/models/stock_picking.py | 68 +++++++++++++++++++++++++++
sf_stock/views/stock_picking.xml | 28 +++++++++--
3 files changed, 103 insertions(+), 25 deletions(-)
diff --git a/sf_sale/views/purchase_order_view.xml b/sf_sale/views/purchase_order_view.xml
index 3b3353bb..bab28456 100644
--- a/sf_sale/views/purchase_order_view.xml
+++ b/sf_sale/views/purchase_order_view.xml
@@ -9,12 +9,16 @@
1
+
+
+
+
-
-
+
-
- 1
-
-
- 1
-
+
@@ -38,13 +37,6 @@
-
-
-
-
- sf_base.group_purchase,sf_base.group_purchase_director
-
-
diff --git a/sf_stock/models/stock_picking.py b/sf_stock/models/stock_picking.py
index a429db36..9b7b22b1 100644
--- a/sf_stock/models/stock_picking.py
+++ b/sf_stock/models/stock_picking.py
@@ -13,6 +13,74 @@ _logger = logging.getLogger(__name__)
class StockPicking(models.Model):
_inherit = 'stock.picking'
+ pro_purchase_count = fields.Integer('坯料采购单数量', compute='_compute_pro_purchase_count', store=True)
+
+ @api.depends('name')
+ def _compute_pro_purchase_count(self):
+ for sp in self:
+ if sp:
+ po_ids = self.env['purchase.order'].sudo().search([
+ ('origin', 'like', sp.name), ('purchase_type', '=', 'standard')])
+ if po_ids:
+ sp.pro_purchase_count = len(po_ids)
+
+ def pro_purchase_order(self):
+ """
+ 坯料采购
+ """
+ po_ids = self.env['purchase.order'].sudo().search([
+ ('origin', 'like', self.name), ('purchase_type', '=', 'standard')])
+ action = {
+ 'res_model': 'purchase.order',
+ 'type': 'ir.actions.act_window',
+ }
+ if len(po_ids) == 1:
+ action.update({
+ 'view_mode': 'form',
+ 'res_id': po_ids.id,
+ })
+ else:
+ action.update({
+ 'name': _("采购订单列表"),
+ 'domain': [('id', 'in', po_ids.ids)],
+ 'view_mode': 'tree,form',
+ })
+ return action
+
+ pro_out_purchase_count = fields.Integer('坯料外协单数量', compute='_compute_pro_out_purchase_count', store=True)
+
+ @api.depends('name')
+ def _compute_pro_out_purchase_count(self):
+ for sp in self:
+ if sp:
+ po_ids = self.env['purchase.order'].sudo().search([
+ ('origin', 'like', sp.name), ('purchase_type', '=', 'consignment')])
+ if po_ids:
+ sp.pro_out_purchase_count = len(po_ids)
+
+ def pro_out_purchase_order(self):
+ """
+ 坯料外协
+ """
+ po_ids = self.env['purchase.order'].sudo().search([
+ ('origin', 'like', self.name), ('purchase_type', '=', 'consignment')])
+ action = {
+ 'res_model': 'purchase.order',
+ 'type': 'ir.actions.act_window',
+ }
+ if len(po_ids) == 1:
+ action.update({
+ 'view_mode': 'form',
+ 'res_id': po_ids.id,
+ })
+ else:
+ action.update({
+ 'name': _("外协订单列表"),
+ 'domain': [('id', 'in', po_ids.ids)],
+ 'view_mode': 'tree,form',
+ })
+ return action
+
# 重写验证,下发发货到bfm
def button_validate(self):
info = super(StockPicking, self).button_validate()
diff --git a/sf_stock/views/stock_picking.xml b/sf_stock/views/stock_picking.xml
index 5bf4d40e..1ecc0d40 100644
--- a/sf_stock/views/stock_picking.xml
+++ b/sf_stock/views/stock_picking.xml
@@ -1,6 +1,28 @@
-
-
-
+
+
+ 添加坯料采购单链接
+ stock.picking
+
+
+
+
+
+
+
+
+
\ No newline at end of file