Hibou Odoo Suite: Purchase by Sale History
The purpose of this documentation is to outline the use case and processes for the Purchase By Sale History for Odoo 12.
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 procure 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 a period of time, where period of time is user-selectable on the wizard.
Once sales for a period of time has been determined, X days worth of of product will be filled as the quantity on the PO, where X days is a 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!
This 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 Request for Quotations (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.When you're ready, click SAVE.
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.