[WIP] replenishment cost based from purchases

The first commit is the one from https://github.com/OCA/margin-analysis/pull/10
This is still work in progress, it seems to work but I intend to add automatic tests.
Early opinons about this feature are welcome however.