logic in stock_minimum_calculator

Bug #615927 reported by Thomas Dreiling
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
openerp-openbig
Fix Released
Undecided
Atik Agewan(OpenERP)

Bug Description

For my example, I assume "today's date" date to be 2010/08/10. Let me quickly layout the logic, again, as we reconsidered and changed it a little. This does not relate to "Calculate without historical consumptions of products", this can be left as is.
1.) We always try to look one year into the past. There is no need for a changeable from_date and to_date. From date is always today's date minus 1 year (i.e. 2009/08/10), to_date is always today's date (i.e. 2010/08/10). Initialize these variables internally and remove the date fields from the wizard. For our purposes, it is enough to calculate with consumptions between the from_date and to_date.
2.) We do not calculate these values neither for single products nor a list of products by brand name or something similar. We always need to calculate this for all products of a certain supplier. So the wizard should be moved from the product context to the supplier (and only there, not all partner types!) context. We can then gather a list of products for which the calculations shall take place by filtering the product_supplierinfo table by the supplier's id.
2.1) We then need to filter out products that do NOT match the following criteria:
- Product Active = True
- Product Type = Stockable Product
- Procure Method = Make to Stock
- Supply Method = Buy
- Can be purchased = True
- State not in ("End of Lifecycle", "Obsolete")
If the "Compute Procurements Only" wizard only takes products with the above criteria into account this filtering is not essential but might improve the overall performance of this wizard.
3.) Next, we need to calculate the average daily consumption (a.d.c.) of the product. Determine the date of the very first stock input for this product. Let's call it "first_input". Now there are three possibilities:
3.1) first_input <= from_date. In this case, the a.d.c. calculates as (consumption between from_date and to_date - refunds between from_date and to_date + open sales orders [state = "In Progress"] - open purchase orders [state = "Approved"]) / (to_date - from_date).
3.2) from_date < first_input < to_date. In this case, the a.d.c. calculates as (consumption between first_date and to_date - refunds between first_date and to_date + open sales orders - open purchase orders) / (to_date - first_date)
3.1) and 3.2) can be combined into a single formula by calculating a.d.c. as (consumption between max(from_date, first_date) and to_date - refunds between max(from_date, first_date) and to_date + open sales orders - open purchase orders) / (to_date - max(from_date, first_date))
3.3) There never was any stock input yet. In this case, the a.d.c. calculates as simply (sum of open sales order - open purchase orders) / (to_date - [date of first open purchase order]). If there are no sales orders or no purchase orders simply skip this product.
4.) Now, we calculate product_min_qty as (a.d.c.) * (supplier_lead_time + purchase_lead_time) * seasonal_factor
5.) For product_max_qty we use two different factors. For products from Asia, product_max_qty = 2 * product_min_qty but for other products, product_max_qty = 1.5 * product_min_qty. We need a new field "Max. Qty. Factor" where the purchasing agent can fill in his respective factor.

We don't need both "Calculate with historical consumptions of product" and "Calculate with historical consumptions of product and Open sales orders". Change it to two selections: "Calculate with planning values" and "Calculate with historical values".

Related branches

Husen Daudi (husendaudi)
Changed in bigconsulting:
assignee: nobody → aag(OpenERP) (aag-openerp)
Revision history for this message
Husen Daudi (husendaudi) wrote :

We have query regarding this.
3.3) There never was any stock input yet. In this case, the a.d.c. calculates as simply (sum of open sales order - open purchase orders) / (to_date - [date of first open purchase order]). If there are no sales orders or no purchase orders simply skip this product.

Here open Sale/Purchase order means draft or In Progress?
If we will consider InProgress Sale order and Purchase order then those SO/PO have picking list attached.
Because when we Open Sale or Purchase order it will create picking for it.

So this case creates conflicts. If you mean draft SO and PO then its fine.

Revision history for this message
Husen Daudi (husendaudi) wrote :

We have committed changes on branch,
can you please test and send us feedback?

Revision history for this message
Thomas Dreiling (thomas-dreiling) wrote : Re: [Bug 615927] Re: logic in stock_minimum_calculator

  Hello,

well, I see. I did mean SO/PO which are "In Progress". But does that
really create a conflict since those pickings won't be done but open, right?

Am 16.08.2010 07:18, schrieb hda (OpenERP):
> We have query regarding this.
> 3.3) There never was any stock input yet. In this case, the a.d.c. calculates as simply (sum of open sales order - open purchase orders) / (to_date - [date of first open purchase order]). If there are no sales orders or no purchase orders simply skip this product.
>
> Here open Sale/Purchase order means draft or In Progress?
> If we will consider InProgress Sale order and Purchase order then those SO/PO have picking list attached.
> Because when we Open Sale or Purchase order it will create picking for it.
>
> So this case creates conflicts. If you mean draft SO and PO then its
> fine.
>

Revision history for this message
Husen Daudi (husendaudi) wrote :

3.3) There never was any stock input yet.(U meant Done Stock Input?)
 In this case, the a.d.c. calculates as simply (sum of open sales order - open purchase orders) / (to_date - [date of first open purchase order]). If there are no sales orders or no purchase orders simply skip this product.

If you meant done stock input then its fine. Because when we open SO/PO it will create open stock picking. thats why we are confused.

Revision history for this message
Thomas Dreiling (thomas-dreiling) wrote :

  Ah, now I got you. Yes, "never any stock input" translates to no "Done
Stock Input".

Am 18.08.2010 08:16, schrieb hda (OpenERP):
> 3.3) There never was any stock input yet.(U meant Done Stock Input?)
> In this case, the a.d.c. calculates as simply (sum of open sales order - open purchase orders) / (to_date - [date of first open purchase order]). If there are no sales orders or no purchase orders simply skip this product.
>
> If you meant done stock input then its fine. Because when we open SO/PO
> it will create open stock picking. thats why we are confused.
>

Husen Daudi (husendaudi)
Changed in bigconsulting:
status: New → Fix Released
Revision history for this message
Thomas Dreiling (thomas-dreiling) wrote :

"Calculate with Out historical consumptions of product" is still in there. This is not needed. Please remove it.

Changed in bigconsulting:
status: Fix Released → In Progress
status: In Progress → New
Changed in bigconsulting:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.