跳至内容
菜单
此问题已终结
1 回复
4044 查看

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
2621
1
1月 22
2557
0
11月 15
3892
2
7月 25
3897
0
6月 21
3033