Members mailing list archives

members@odoo-community.org

Re: [V8][PORT] margin-analysis (product_get_cost_field / product_standard_margin)

by
Alexinux, Alexis de Lattre
- 22/07/2015 15:24:03


2015-07-22 15:37 GMT+02:00 Sébastien LANGE (SYLEAM) <sebastien.lange@syleam.fr>:
Alexis, the history cost is in product_price_history table

OK, I see that in odoo/addons/product/product.py ; and the entries are created via an inherit of write/create on the field 'standard_price' of product_template. But it seems that this object "product_price_history" is not displayed in the view of products, which makes it difficult to read the history of prices and verify the data ! And it's also more difficult to be aware of this object if it's not displayed anywhere !
 
and in the quants.

Oh yes, I forgot about those :)

Given all this and the new API, it seems to me that it would be easier to write a new module that will do the same job as "product_historical_margin" that to port the existing module. In fact, in the current module 'product_historical_margin', the fields 'subtotal_cost_price_company', 'subtotal_cost_price', etc... are function fields ; this is OK for the old API where the fields are not invalidated by default unless you write a specific invalidation method, but function fields don't work like that in the new API and you have the risk to have the function fields invalidated when you don't want to.

So I think that we need 2 modules in v8 to replace "product_historical_margin" :
- one small module that copies the field standard_price on the account.invoice.line (via an inherit of create/write of the account.invoice.line) ; we could name it "account_invoice_line_standard_price"
- a module for "BI" that adds stored computed fields on account.invoice.line to have the amounts in company currency (and negative when it's a refund), margins, etc...

I think it's the best solution, what do you think ?

Regards,

--
Alexis de Lattre
Akretion France - 35B rue Montgolfier - 69100 Villeurbanne - France
Mail : alexis.delattre@akretion.com
Tel : +33 4 82 53 84 58
Mobile : +33 6 99 08 92 45
Jabber/Gtalk : alexis.delattre@akretion.com.br