Report "product cost structure" doesnt calculate components costs

Bug #689868 reported by Francis Pierrat
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
New
Undecided
OpenERP Publisher's Warranty Team

Bug Description

Products A, B, C and D.
standard prices are 1€.

BoM for Product A: 1B + 4C
BoM for product B: 10D
(so one A should be composed of 10D + 4B, and in fact that's what the procurement orders do)

When calculating A's "product cost structure" report,
------------ I'm awaiting:
Costs A :
  1 x costs B
      10 x costs D = 10 x 1€
  4 x costs C = 4 x 1 €
Total costs for one A : 14€

------------ BUT INSTEAD OF THIS, IT ...
... calculates A costs using A's BoM (A= 1B + 4C)
... doesn't calculate B's costs using B's BoM (B=10D).
     Instead of this, creates a new B's "BoM components", with no other products in it.
     Cost of one B = 1 x standard price of B = 1€
Costs A = 1x standard price of B + 4x standard price of C = 1€ + 4€ = 5€

------------ Note:
The report "BoM structure" is correct, it gives :
A
    1B
        10D
    4C

Thanks in advance for correcting this bug (or for explanation if I'm understanding something wrong)

Revision history for this message
Francis Pierrat (fpierrat) wrote :

Naive remarks after analysing some files (I don't speak python fluently, and never developed anything around OpenErp, so don't be too hard if it's stupid!).

The data for the report seems to be assembled in addons\mrp\report\price.py
There I can read:

        for prod_id in ids:
            bom_ids = pooler.get_pool(cr.dbname).get('mrp.bom').search(cr, uid, [('product_id','=',prod_id)])
            prod = pooler.get_pool(cr.dbname).get('product.product').browse(cr, uid, prod_id)

            for bom_id in bom_ids:
                bom = pooler.get_pool(cr.dbname).get('mrp.bom').browse(cr, uid, bom_id)

                sub_boms = pooler.get_pool(cr.dbname).get('mrp.bom')._bom_explode(cr, uid, bom, number, [])

From the last line above, it seems to me it just checks the sub-boms (bom components?) included in the first bom, but NOT the boms of the included products that would have their own boms independantly and not as sub_boms.
Would it be possible here to complete this "sub_boms" array, with the boms of the products included in the first bom?
Something like
    products_used=pooler.get.......(products in the bom)
    boms_of_used_products = pooler.get (boms of used products)
    all_boms_to_consider = sub_boms + boms_of_used_products
I really think the problem is here, even if I fairly doubt the solution can look like this... once again, don't be too hard with a nondevelopper newcomer looking forward to help solving his own problem... ;-)

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Francis,

I have tested your scenario.You made a some wrong configuration in your "BoM". so please consider following steps.

1. Make a 4 different product A,B.C, and D.
2.Then make a "BoM" and select the BoM type as a "Sets / Phantom".
3. And define in this one "BoM" your whole structure like in product A 's component define product B and in Product B's component define product C.
4. Now you print the "Product Cost Structure" report which contains cost of product is 14€.

When you select "BoM" type as a "Normal" then only it's sub-product 's structure can generated not of the sub-product 's child. So in "Product Structure Cost" report you can see the cost of the product was 5€.
But when you select "BoM" type as a "Sets / Phantom" then it will consider it's children.Then it's cost calculated to it's sub-product and also in sub-product's children.

Thanks

Changed in openobject-addons:
status: New → Invalid
Revision history for this message
Francis Pierrat (fpierrat) wrote :

Hello,

Thanks for your answer.

I'll test it like this BUT I'm not sure it'll be absolutely satisfying:
I had simplified my structure for the example, but it merely looks like this:

A
  B
  C
    D
      E
        F
        G
        H
      I
    J
      K
      L
  M

So A must be "phantom" so that it considers C's BoM, then probably C must be phantom to consider D's & J's BoMs, and D must be phantom to consider E's BoM...
I'm afraid of the side-effects of phantom-BoMs, I don't want at once thousands of procurements of things that aren't ready to buy or produce now, to be accepted at once in one single procurement order because of phantom BoMs.

Clearer explained: I want to be able to accept C's procurement order when B is ready.
With phantom Boms quite everywhere,
- instead of 1 procurement order for B, C & M,
- I'll have one for B, F, G, H, I, K, L, M,
am I right?
With all difficulty to clearly see where all these procurements come from or belong to (caus all our A, A', A'', A''' and so on products use the same components).

So it seems really strange to me that I have to simulate phantoms where I don't need phantoms according to my process, just for a cost report to function properly.

So I quite disagree with you, I think it quite looks like a bug.
How do you explain that the report "Bom structure" IS ABLE to recursively find the boms of the components (pic 1 of the attachment),
And that the report "product cost structure" IS NOT ABLE to do the same? There's no phantom BoM in either case... (pic 2)

So I would be grateful if you admitted to reconsider this:
** Changed in: openobject-addons
       Status: New => Invalid

Revision history for this message
Francis Pierrat (fpierrat) wrote :

Attachment missing in previous message

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Francis,

I have tested your latest scenario. But it is also giving the proper result. I have created this structure.

A
  B
  C
    D
      E
        F
        G
        H
      I
    J
      K
      L
  M
And all product's cost is 1.00. Now calculated product A 's cost structure. Product A was created with sub product B,C,M and C was created with sub product D,J same D was created with sub-product E,I same E was created sub product F,G,H, same J product was created with sub product K and L. So the product A 's cost structure = (1+C's cost+1) C's cost is D's Cost + J's Cost Now D's cost is (E+I) and E 's Cost is F+G+H's cost . So D's cost is 4.0 and J's cost is 2 . So now C's cost is 6 . so Total Cost of product A is 1+6+1=8.00 which is our result. I have attached two screen-shots of it for your reference.

Thanks.

Revision history for this message
Amit Parik (amit-parik) wrote :
Revision history for this message
Amit Parik (amit-parik) wrote :
Revision history for this message
Francis Pierrat (fpierrat) wrote :

This is with C declared as phantom in A, and D declared as phantom in C and so on, or am I misunderstanding?

With phantom, I DO AGREE the cost calculation will be OK.

BUT in my process, it shall NOT be phantom, I do NOT want purchase orders to be produced at once for all sub-sub-sub-sub-products needed, it'll be unnecessarily confusing.

If it's possible to reach you directly, maybe it'll be easier and quicker to understand each other per phone, I've got the feeling we don't exactly talk about the same thing...

Anyhow, thanks for considering my issue.

Revision history for this message
mathias123 (matze251284) wrote :

Is there a solution yet? Would be interesting for me too...

Revision history for this message
Francis Pierrat (fpierrat) wrote : RE: [Bug 689868] Re: Report "product cost structure" doesnt calculate components costs

Sorry, I finally didn't migrate to OpenERP, so I don't know if this problem has been solved by now.

Francis Pierrat
Directeur Financier
MVS Group / Pôle Musique
395 chemin de la Cartonnerie - BP 294
88108 Saint Dié cedex
03 29 56 19 42 - <email address hidden>

-----Message d'origine-----
De : <email address hidden> [mailto:<email address hidden>] De la part de mathias123
Envoyé : jeudi 13 décembre 2012 17:15
À : <email address hidden>
Objet : [Bug 689868] Re: Report "product cost structure" doesnt calculate components costs

Is there a solution yet? Would be interesting for me too...

--
You received this bug notification because you are subscribed to the bug report.
https://bugs.launchpad.net/bugs/689868

Title:
  Report "product cost structure" doesnt calculate components costs

Status in OpenERP Addons (modules):
  Invalid

Bug description:
  Products A, B, C and D.
  standard prices are 1€.

  BoM for Product A: 1B + 4C
  BoM for product B: 10D
  (so one A should be composed of 10D + 4B, and in fact that's what the procurement orders do)

  When calculating A's "product cost structure" report,
  ------------ I'm awaiting:
  Costs A :
    1 x costs B
        10 x costs D = 10 x 1€
    4 x costs C = 4 x 1 €
  Total costs for one A : 14€

  ------------ BUT INSTEAD OF THIS, IT ...
  ... calculates A costs using A's BoM (A= 1B + 4C)
  ... doesn't calculate B's costs using B's BoM (B=10D).
       Instead of this, creates a new B's "BoM components", with no other products in it.
       Cost of one B = 1 x standard price of B = 1€
  Costs A = 1x standard price of B + 4x standard price of C = 1€ + 4€ = 5€

  ------------ Note:
  The report "BoM structure" is correct, it gives :
  A
      1B
          10D
      4C

  Thanks in advance for correcting this bug (or for explanation if I'm
  understanding something wrong)

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/689868/+subscriptions

Changed in openobject-addons:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
status: Invalid → New
tags: added: maintenance
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.