Open TelmoSuarezConinpe opened 1 year ago
Hello TelmoSuarezConinpe,
Did you find a workaround for this problem ? I have encountered it too and I can't find how to make this work.
Thanks.
I finally found a correction for this problem. For V14, you need to update the file sale_procurement_group_by_line/model/sale.py
First, you need to import odoo.api :
from odoo import fields, models, **api**
Then you need to override SaleOrder class by adding this code before the SaleOrderLine class definition :
class SaleOrder(models.Model):
_inherit = 'sale.order'
@api.depends('order_line.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id', 'order_line.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id')
def _compute_purchase_order_count(self):
super(SaleOrder, self)._compute_purchase_order_count()
def _get_purchase_orders(self):
return super(SaleOrder, self)._get_purchase_orders() | self.order_line.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | self.order_line.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id
Explanation :
In module sale_purchase_stock, the method _get_purchase_orders
uses the property procurement_group_id
of the SaleOrder class to retrieve purchase orders. But when module sale_delivery_split_by_date is installed, procurement_group_id is not used anymore on the SaleOrder. Instead, procurement groups are linked to purchase order lines. So without the fix, _get_purchase_orders returns an empty list of PO.
The fix adds the PO from self.order_line.procurement_group_id the same way that module sale_purchase_stock adds it from self.procurement_group_id. With it, when you confirm a SO the corresponding PO is properly linked and the smart button appears correctly.
I will try to propose a pull request so that this fix is integrated into the module.
@TelmoSuarezConinpe would you mind reviewing/testing this PR? https://github.com/OCA/sale-workflow/pull/2613
It should solve this issue.
module: sale_procurement_group_by_line version: 15.0
Steps to reproduce
Current behavior In the SO there is no smart button with the related PO
Expected behavior Additional smart button on the SO with the related PO