Skip to Content
Menu
This question has been flagged
1 Reply
2800 Views

Hi i am using odoo 14 community edition, when i use bom structure and cost from manufacturing module, the product cost for each components is same as BoM Cost , why is it the same , i want to display each products unit cost in product cost and the total cost(quantity*product cost) in bom cost for each component how can this be made possible. using any configuration, python,xml or is there any free module to achieve the same. This is snippet of the error. Thank you


Avatar
Discard

Hello jo,

I think there is no any free module that achieve your goal. You have to create customize module for that.

Author

@Shivoham can you tell me how can i create a custom module for this what do i need to inherit to change product cost in this

Best Answer

Hello Jo,

You can create new py file and rewrite the method _get_bom_lines of mrp_report_bom_structure and assign it.

Kindly Refer below example.


from odoo\.addons\.mrp\.report\.mrp_report_bom_structure\ import\ ReportBomStructure


def\ _get_bom_lines\(self,\ bom,\ bom_quantity,\ product,\ line_id,\ level\):
\ \ \ \ \ \ \ \ components\ =\ \[\]
\ \ \ \ \ \ \ \ total\ =\ 0
\ \ \ \ \ \ \ \ for\ line\ in\ bom\.bom_line_ids:
\ \ \ \ \ \ \ \ \ \ \ \ line_quantity\ =\ \(bom_quantity\ /\ \(bom\.product_qty\ or\ 1\.0\)\)\ \*\ line\.product_qty
\ \ \ \ \ \ \ \ \ \ \ \ if\ line\._skip_bom_line\(product\):
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ continue
\ \ \ \ \ \ \ \ \ \ \ \ company\ =\ bom\.company_id\ or\ self\.env\.company
\ \ \ \ \ \ \ \ \ \ \ \ price\ =\ line\.product_id\.uom_id\._compute_price\(line\.product_id\.with_company\(company\)\.standard_price,\ line\.product_uom_id\)
\ \ \ \ \ \ \ \ \ \ \ \ if\ line\.child_bom_id:
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ factor\ =\ line\.product_uom_id\._compute_quantity\(line_quantity,\ line\.child_bom_id\.product_uom_id\)
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sub_total\ =\ self\._get_price\(line\.child_bom_id,\ factor,\ line\.product_id\)
\ \ \ \ \ \ \ \ \ \ \ \ else:
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sub_total\ =\ price\ \*\ line_quantity
\ \ \ \ \ \ \ \ \ \ \ \ sub_total\ =\ self\.env\.company\.currency_id\.round\(sub_total\)
\ \ \ \ \ \ \ \ \ \ \ \ components\.append\(\{
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'prod_id':\ line\.product_id\.id,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'prod_name':\ line\.product_id\.display_name,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'code':\ line\.child_bom_id\ and\ line\.child_bom_id\.display_name\ or\ '',
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'prod_qty':\ line_quantity,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'prod_uom':\ line\.product_uom_id\.name,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'prod_cost':\ company\.currency_id\.round\(price\),
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'parent_id':\ bom\.id,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'line_id':\ line\.id,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'level':\ level\ or\ 0,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'total':\ sub_total,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'child_bom':\ line\.child_bom_id\.id,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'phantom_bom':\ line\.child_bom_id\ and\ line\.child_bom_id\.type\ ==\ 'phantom'\ or\ False,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'attachments':\ self\.env\['mrp\.document'\]\.search\(\['\|',\ '\&',
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \('res_model',\ '=',\ 'product\.product'\),\ \('res_id',\ '=',\ line\.product_id\.id\),\ '\&',\ \('res_model',\ '=',\ 'product\.template'\),\ \('res_id',\ '=',\ line.product_id.product_tmpl_id.id)]),

})
total += sub_total
return components, total

ReportBomStructure._get_bom_lines = _get_bom_lines


Avatar
Discard
Related Posts Replies Views Activity
1
Apr 22
1765
1
Jan 22
1461
0
Nov 15
3069
1
Feb 23
2722
0
Jun 21
1682