Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

Re: Inventory on a past date ?

by
Akretion, Clément Mombereau
- 19/11/2021 12:12:57
Thanks a lot Lois and Richard !

Indeed, rewriting history looks very dangerous. Maybe if you are in standard cost method as you did with stock_account_inventory_force_date you achieve something not so bad without too much effort (even if I imagine it won't be trivial to migrate this module to v14 due to the big changes with the new stock.valuation.layer model)... but my client does not use the standard cost method (neither will someone who wants such an advanced feature on Inventory adjustment, i guess).

But I really liked the strategy suggested by Richard. In fact, when talking with my client on how he would be able to do this "Inventory on past date" with the Odoo actual limits, we were exactly heading towards this idea... but manually at first.

Thus the process without any development would be :
1. He registers the physical inventory in Odoo on the day it is done, without double checking
2. Few days later, he checks the stock changes made by this inventory adjustment. If he finds an error on some inventory lines already registered, he would have to :
    2.1. Check all the new product's stock.move since the inventory date and calculate the related product's quantity variation
    2.2. Make a new inventory adjustment for the correction, including this variation since the inventory.

So yes, maybe I can make a small module which automates this calculation :
- Adding a "past_date" field in stock.inventory main form
- For each inventory line it would calculate the "old_past_qty_on_hand" for the related (product_id, lot_id, location_id), calculating the stock.move.line's variation for this triplet since past_date... (a bit like in stock_account_inventory_force_date's _get_inventory_lines_values)
- When recording the Inventory lines, it would create an adjustment stock.move on today's date, but with a quantity of
      new_past_qty_on_hand - old_past_qty_on_hand + qty_variation_since_past_date

Do you agree with this idea ?

Thanks again!

Abraço,
Clément.

Le ven. 19 nov. 2021 à 10:32, Lois Rilo Antelo <lois.rilo@forgeflow.com> a écrit :
Hi Clement,

You can have a look at this module https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_account_inventory_force_date. It does not cover all the cases, if you do not use standard cost it can at least get you half the way. I'll be glad to review any improvement you can come up with.

Best regards,

El jue, 18 nov 2021 a las 17:12, Richard deMeester (<richard.demeester@willdooit.com>) escribió:

Hi Clément.

In older versions, we had a stock freeze function.

You freeze the figures at the point in time you want to count them.  The adjustment is made when you apply (the stock moves need to be dated at the current date/time) but rather than comparing against the current on hand, we compare them against the frozen quantity.

Example:

Freeze quantity: 5
Current quantity: 9
Counted quantity: 4

Stock adjustment is then for -1, creating a new onhand of 8

Now, it should be possible to instead of having a freeze quantity, pick up the quantity on hand at a past time (with to_date in the context) and that would achieve the same result, in my quick thinking.

But you really need the adjustment to be written as of now, not as at the past time.  It could screw up so much trying to backdate the move itself....

Richard



Richard deMeester

Senior Development Analyst

WilldooIT Pty Ltd

E: richard.demeester@willdooit.com

M: +61 403 76 76 76

P: +61 3 9135 1900

A: 10/435 Williamstown Road, Port Melbourne, Vic 3207

 

 

Making growth through technology easy

 

 

DISCLAIMER | This electronic message together with any attachments is confidential. If you are not the recipient, do not copy, disclose, or use the contents in any way. Please also advise us by e-mail that you have received this message in error and then please destroy this email and any of its attachments. WilldooIT Pty. Ltd. is not responsible for any changes made to this message and/or any attachments after sending by WilldooIT Pty. Ltd. WilldooIT Pty. Ltd. use virus scanning software but exclude all liability for virus or anything similar in this email or attachment.



From: Clément Mombereau <clement.mombereau@akretion.com.br>
Sent: Friday, 19 November 2021 3:01 AM
To: Contributors <contributors@odoo-community.org>
Subject: Inventory on a past date ?
 
Hello contributors,

There is a few days delay between the moment the physical inventory is done at my client's warehouses and the moment he actually registers this inventory adjustment in Odoo.
So he would like to make inventory adjustments on a past date (only a few days ago mainly).

Anyone have an idea on how to achieve this ?

There is this accounting_date on stock.inventory but it looks like it only forces the account.move's date related to the inventory adjustment.

As far as I've understood the problem, when we click on Inventory's "action_start" it catches the  quants quantities... And a quant by definition can only shows the actual product quantity in stock.

So instead, it would mean to recalculate the past stock.moves for each products, a bit like what is done with the _compute_quantities when clicking on "Inventory at date" in the Inventory Report menu... (the big difference with this "_compute_quantities" being that we would have to group the moves calculation by location_id and lot_id because we need to make these distinctions)

Anyway, it does not look so easy at first glance. At least, would it be the good method to achieve this inventory on a past date?

Thank you very much for your opinion on this topic! 🙏

Abraço,
Clément.

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe



--
Lois Rilo Antelo
Odoo consultant at ForgeFlow S.L.

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

Reference