Files
odoo_source/addons/stock_dropshipping/models/stock.py
T
Rémy Voet (ryv) 5a1645a8f8 [ADD] sale_purchase_stock: link between PO<->SO in case of MTO
In order to improve the navigation between of SO and PO in the case of
MTO, add a direct link between PO<->SO. When the SO is confirmed
(with storable product(s) with MTO + buy),
PO is/are generated, in this case, add a stat button on each model form
to avoid to manually search the related SO with the source field (name).

task-1913392
2020-01-23 14:59:57 +00:00

31 lines
1.2 KiB
Python

# -*- 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)