From 18c7b22319be97a6e50b91001217def5315ea7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Thu, 8 May 2025 16:47:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E9=87=87=E8=B4=AD=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E5=90=88=E5=B9=B6=E6=98=8E=E7=BB=86=E8=A1=8C=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=8C=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E5=90=8E=E7=BB=AD=E5=8D=95=E6=8D=AE=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jikimo_purchase_request/models/stock_rule.py | 62 ++++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/jikimo_purchase_request/models/stock_rule.py b/jikimo_purchase_request/models/stock_rule.py index 81f4f8ee..c9c3dc8c 100644 --- a/jikimo_purchase_request/models/stock_rule.py +++ b/jikimo_purchase_request/models/stock_rule.py @@ -46,38 +46,38 @@ class StockRule(models.Model): def _run_buy(self, procurements): # 如果补货组相同,并且产品相同,则合并 - procurements_dict = defaultdict() - for procurement, rule in procurements: - if (procurement.product_id, procurement.values['group_id'], rule) not in procurements_dict: - procurements_dict[(procurement.product_id, procurement.values['group_id'], rule)] = { - 'product_id': procurement.product_id, - 'product_qty': procurement.product_qty, - 'product_uom': procurement.product_uom, - 'location_id': procurement.location_id, - 'name': procurement.name, - 'origin': procurement.origin, - 'company_id': procurement.company_id, - 'values': procurement.values, - 'rule': rule - } - else: - procurements_dict[(procurement.product_id, procurement.values['group_id'], rule)]['product_qty'] += procurement.product_qty - new_procurements = [] - for k, p in procurements_dict.items(): - new_procurements.append(( - self.env['procurement.group'].Procurement( - product_id=p['product_id'], - product_qty=p['product_qty'], - product_uom=p['product_uom'], - location_id=p['location_id'], - name=p['name'], - origin=p['origin'], - company_id=p['company_id'], - values=p['values'] - ), p['rule']) - ) + # procurements_dict = defaultdict() + # for procurement, rule in procurements: + # if (procurement.product_id, procurement.values['group_id'], rule) not in procurements_dict: + # procurements_dict[(procurement.product_id, procurement.values['group_id'], rule)] = { + # 'product_id': procurement.product_id, + # 'product_qty': procurement.product_qty, + # 'product_uom': procurement.product_uom, + # 'location_id': procurement.location_id, + # 'name': procurement.name, + # 'origin': procurement.origin, + # 'company_id': procurement.company_id, + # 'values': procurement.values, + # 'rule': rule + # } + # else: + # procurements_dict[(procurement.product_id, procurement.values['group_id'], rule)]['product_qty'] += procurement.product_qty + # new_procurements = [] + # for k, p in procurements_dict.items(): + # new_procurements.append(( + # self.env['procurement.group'].Procurement( + # product_id=p['product_id'], + # product_qty=p['product_qty'], + # product_uom=p['product_uom'], + # location_id=p['location_id'], + # name=p['name'], + # origin=p['origin'], + # company_id=p['company_id'], + # values=p['values'] + # ), p['rule']) + # ) - res = super(StockRule, self)._run_buy(new_procurements) + res = super(StockRule, self)._run_buy(procurements) # 判断是否根据规则生成新的采购申请单据,如果生成则修改状态为 approved origins = list(set([procurement[0].origin for procurement in procurements])) for origin in origins: