Skip to content

[18.0] Smart button on sale order with link to purchase orders is not shown #3864

@vince-dynapps

Description

@vince-dynapps

Module

sale_procurement_group_by_line

Describe the bug

If you confirm a sales order with MTO (make to order) products, Odoo will automatically create a purchase order and show a smart button on the sales order with al ink to the created purchase order(s). This button disappears if you install the sale_procurement_group_by_line module.

The following function computes the purchase orders to show in the smart button:

    def _get_purchase_orders(self):
        self.ensure_one()
        linked_po = self.procurement_group_id.stock_move_ids.created_purchase_line_ids.order_id \
                  | self.env['stock.move'].browse(self.procurement_group_id.stock_move_ids._rollup_move_origs()).purchase_line_id.order_id
        group_po = self.procurement_group_id.purchase_line_ids.order_id

        return linked_po | group_po

If I install the sale_procurement_group_by_line module, the procurement_group_id will be stored on the individual sale order lines so the function above needs to be rewritten to take this into account.

To Reproduce

18.0

Steps to reproduce the behavior:

  1. Configure a product with the MTO/Buy routes enabled. Make sure a vendor is configured so Odoo knows for which vendor it needs to create a purchase order
  2. Make a sales order to sell the configured product
  3. Confirm the sales order and verify a purchase order is generated by Odoo. The smart button should show the created purchase orders but it doesn't.

Expected behavior
I would expect that the standard Odoo functionality keeps working. The smart button with a link to purchase orders should still be visible on the sales order.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions