Add wizard to account the stock valuation

Continuing the discussion from How to create account move for goods on the way:

Rational

There are some companies that just create a move with all the inventory value moves at the end of the period/fiscalyear. Currently this should be done manually, but when managing a large amount of products this is quiet tedious.

Proposal

Add a wizard that computes the valuation of goods at date selected by the user. With this valuation a new account move is created with the credit debit values needed to update the balance of each product account to the valuation at the given date.

This wizard should be only accessible for companies and dates which a fiscalyear that has the accounting method set as manual.

To execute the wizard the user should have closed an account period for the given date. This way we ensure that no changes are done after the balances are updated.

Implementation

https://bugs.tryton.org/issue9780

I’m not sure how to structure this as it requires to use some concepts already available on the account_stock_continental module:

  1. The accounts (stock, stock_in and stock_out) used for each accounting category
  2. The stock journal defined on the account configuration.

I see two options here:

  1. Create a new account_stock module which defines the common concepts of all of the account_stock_* modules and create a new account_stock_wizard module which implements the required features.
  2. Move everything to the new module where we should implement the wizard and add this module as dependency of the current account_stock_continental module.

I would add a third option, which is adding it to account_product module.

How will you compute the variation? Because you must only book the variation of value.
I guess we could compute the target balance for each account and take the balance of each account at that date. So the move line will be the difference.

Also how will it work for accounting that are doing COGS?

Also I think it will require that the stock period is closed to ensure no more change will happen.

For me it increase the complexity to have a empty shell module. Also a module just for a wizard seems overkill.

This sounds like the right way.

I do not see why, this module does not depend on stock. It would be wrong to add such dependencies for setup that requires only accounting and invoicing.

You guess is right. That was my idea.

The idea is to not manage COGS on manual accounting. If there is the need of COGS you should switch to Anglo-Saxon accounting which is based on moves like continental.

Makes sense. I add it to the proposal.

Indeed it could be done if on account_stock_anglo_saxon the COGS move was done on invoice also for a manual-anglo-saxon method but using the current cost price of the goods.
I think it is something that should be handled if we add a manual method.

So IIUC when using the manual-anglo-saxon method, the wizard should take care to correctly compute and update the COGS balance?

I do not think you can valuate the COGS at the end of the period.
I think it is better that the invoice keep filling COGS when posted. So the move posted by the wizard stays the same but the invoice must do the posting.

I’ve filled Issue 9780: Add wizard to balance stock - Tryton issue tracker which implements the wizard.
It will be great to have some feedback about it.