コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
4374 ビュー

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


アバター
破棄

Hello jo,

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

著作者

@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

最善の回答

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


アバター
破棄
関連投稿 返信 ビュー 活動
1
4月 22
2796
1
1月 22
2796
0
11月 15
4131
2
7月 25
4141
0
6月 21
3264