# Sale Order Line Multi Warehouse

This module allows to select multiple warehouses in sale order lines so the sale order is split into multiple pickings depending on the warehouses selected in the lines.

Table of contents

- Configuration
- Usage
- Known issues / Roadmap
- Bug Tracker
- Credits
  - Authors
  - Contributors
  - Maintainers

## Configuration

To activate the sale orders multi-warehouse options you need to:

1. Go to Inventory > Configuration > Settings.
2. Activate the “Multi Warehouse in Sale Orders” option, under the “Warehouse” section. This field is only visible for users in group “Inventory / Administrator”. When a sale order is created, multi warehouse options in sale order lines will be enabled/disabled depending on the value in this field on creation.

It is necessary to set alternative warehouses to a warehouse so they can be selected in sale order lines when the warehouse is set in the “Warehouse” field in a sale order. To set alternative warehouses you need to:

1. Go to Inventory > Configuration > Warehouses and see a warehouse’s form view.
2. Select the warehouse’s alternative warehouses in the “Altenative Warehouses” field. This field is only visible for users in group “Inventory / Administrator”.

## Usage

- To split a sale order line into multiple warehouses you need to click on the tree graph icon in a sale order line. A popup will open, where warehouses and quantities can be selected. Only the warehouses set in the “Alternative Warehouses” field in the warehouse set in the sale order can be selected. Sale order line quantity and its warehouse distributions line quantities are synchronized as follows:
    - When quantity is increased in a sale order line:
        - In case there is a warehouse distribution line related to the warehouse set in the sale order, the increased quantity is added to the quantity in this warehouse fistribution line.
        - In case there is not a warehouse distribution line related to the warehouse set in the sale order, a new warehouse distribution line related to the warehouse set in the sale order is created containing the increased amount.
    - When quantity is decreased in a sale order line:
        - In case there is a warehouse distribution line related to the warehouse set in the sale order, the decreased quantity is substracted from the quantity amount in this warehouse distribution line. When the amount set in this warehouse distribution line is not enough, the pending amount is randomly substracted from the rest of warehouse distribution lines.
        - In case there is not a warehouse distribution line related to the warehouse set in the sale order, the decreased quantity is randomly subsctracted from the available warehouse distribution lines.
    - When quantity is modified in a warehouse distribution line, the amount in the sale order line is automatically updated so it matches the total amount in the sale warehouse distribution lines.
- When the multi warehouse options in sale order lines are enabled, changing the general sale order warehouse needs to be done through a wizard, located in the “Other Info” tab, in the “Delivery” section. The button is only visible for users in group “Technical / Manage Multiple Warehouses”.
- A sale order line cannot have multiple warehouse distribution lines related to the same warehouse.
- Once the sale order is validated, the order will be split into multiple pickings, one for each warehouse selected in the warehouse distribution lines.
- IMPORTANT: In case this module is uninstalled, the warehouse distribution lines will be lost.

## Known issues / Roadmap

- The warehouse distribution lines display could be improved in the future so it looks similar to the pop up used for analytic distribution.
- Module sale_procurement_group_by_line should not be used along with this module as it provides the base to split sale order lines depending on different criteria, which might make sale_order_line_multi_warehouse module malfunction.

## Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

## Credits

### Authors

- Sygel

### Contributors

- Manuel Regidor <manuel.regidor@sygel.es>
- Valentín Vinagre <valentin.vinagre@sygel.es>

### Maintainers

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

This module is part of the OCA/sale-workflow project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.