Hibou Odoo Suite: Purchase Modules: Purchase by Sale History
This documentation outlines the use case and processes for the Purchase By Sale History module for Odoo 14.
The Purchase by Sale History wizard reviews product sales history from previous months, then calculates and increments the quantity to purchase for each product based on the number of months you wish to buy in order to have stock on hand.
When launched, this wizard does the following:
If no products are on the Request for Quotation/Purchase Order, then the wizard looks at all products supplied by the selected vendor.
If there are products are on the Request for Quotation/Purchase Order, then the wizard looks at only those products.
The wizard then looks at sales history to determine how much has sold over time-period set by the user.
Once sales are determined for a time-period, X days worth of of product will be populated as the quantity on the PO, where X days is that user-input field on the wizard.
To get started, navigate to the Apps application.
Once there, remove the 'Apps' filter from the search field and search for "Purchase by Sale History". When you're ready, click INSTALL.
Good to Know!
The Purchase by Sale History module requires Sales and Purchase apps to be installed; however, if you do not already have these modules installed, Odoo will install them for you during this module's installation.
Next, navigate to the Purchase app.
Creating the Request for Quotation/Purchase Order
This will bring you to a list view of all Requests for Quotation (RFQ). Click CREATE.
Select the vendor from whom you are purchasing from the Vendor drop-down. If you would like to purchase specific products at this time, add those products to the RFQ by clicking ADD A line. At this point, you can add products before running the wizard or not at all.
Using the Purchase by Sale History Wizard
Click the Fill by Sales button that now displays.
This brings up the Fill PO From Sales History modal window with the following fields.
Sales History Start: The first day the wizard should look at to calculate sales history for each product. This date field is automatically set to 30 days before today, but can be changed if desired.
Sales History End: The last day the wizard should look at to calculate sales history for each product.This date field is automatically set to today, but can be changed if desired.
Days to Procure: How many days of stock the wizard should calculate and add to the RFQ, based on the sales history data from Sales History Start through Sales History End. This field is automatically set to 30 days, but can be changed if desired.
Warehouses: Sales are calculated by these warehouses and current inventory is summed from these warehouses If this is left blank, then all warehouses and inventory will be considered.
Two additional fields will be displayed, but are not user editable:
History Days: Based on the Sales History Start and Sales History End inputs, the number of days of sales history that will be reviewed by the wizard.
Product Count: Products on the RFQ or products that the vendor provides, if no products were added to the RFQ.
When all fields are completed, click Run.
Depending on History Days and Product Count it may take several moments for the wizard to run its calculations.
When the wizard has completed its calculations, the Qty column for each product will be incremented to the appropriate quantity based on your Days to Procure selection. If no products were added to the RFQ, it will now have all products supplied by the selected vendor that must be purchased in order to meet your Days to Procure selection.
This module adds a new transient model `purchase.sale.history.make` with the following fields:
`purchase_id` Many2one field
`history_start` date field
`history_end` date field
`history_days` integer field
`procure_days` integer field
`product_count` computed field
`history_warehouse_ids` Many2many field
Additionally, it includes various methods used in the product computation count using the sales history to make an average per day, along with the form view for the wizard.