summaryrefslogtreecommitdiff
path: root/addons/stock_dropshipping/models/stock.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/stock_dropshipping/models/stock.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/stock_dropshipping/models/stock.py')
-rw-r--r--addons/stock_dropshipping/models/stock.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/addons/stock_dropshipping/models/stock.py b/addons/stock_dropshipping/models/stock.py
new file mode 100644
index 00000000..c44fe2cc
--- /dev/null
+++ b/addons/stock_dropshipping/models/stock.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, models
+
+
+class StockRule(models.Model):
+ _inherit = 'stock.rule'
+
+ @api.model
+ def _get_procurements_to_merge_groupby(self, procurement):
+ """ Do not group purchase order line if they are linked to different
+ sale order line. The purpose is to compute the delivered quantities.
+ """
+ return procurement.values.get('sale_line_id'), super(StockRule, self)._get_procurements_to_merge_groupby(procurement)
+
+ @api.model
+ def _get_procurements_to_merge_sorted(self, procurement):
+ return procurement.values.get('sale_line_id'), super(StockRule, self)._get_procurements_to_merge_sorted(procurement)
+
+
+class ProcurementGroup(models.Model):
+ _inherit = "procurement.group"
+
+ @api.model
+ def _get_rule_domain(self, location, values):
+ if 'sale_line_id' in values and values.get('company_id'):
+ return [('location_id', '=', location.id), ('action', '!=', 'push'), ('company_id', '=', values['company_id'].id)]
+ else:
+ return super(ProcurementGroup, self)._get_rule_domain(location, values)