Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3917 Lượt xem

I am new in odoo 12, I wanted to calculate the margin for sale order line based on BoM Cost,
What should I do about this?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

If you want to calculate margin based on bom cost, please try for below code.
I used in V12 but hope, it will work for you.

GOTO > BoM > Open Any BoM > Click on Structrure & Cost (Chagnes Quantity)

You can get Cost from there, cost is depeneds on Quantity.

To calculate on Sale Order you need to define one compute field.

Add this field on Sale Order Line form viewbom_price = fields.Float(
bom_price = fields.Float(
       compute='_compute_so_line_bom_price',

        store=True,

        string='BoM Cost')

Add this field on Sale Order Line form view


@api.depends('product_id', 'product_uom_qty')
def _compute_so_line_bom_price(self):
    """Compute: Product BoM Cost Price.
        Compute the BoM Cost Price using _bom_find method of MRP BoM object and
        _get_bom method of BoM Structure and Cost Report
        (BoM > Smart Button: Structure & Cost).

        :return: None
        """
        mrp_bom = self.env['mrp.bom']
        bom_report = self.env['report.mrp.report_bom_structure']
        for res in self:
                price = 0
                if res.product_id and res.product_uom_qty:
                    bom = mrp_bom._bom_find(product=res.product_id)
                    if bom:
                        price = bom_report._get_bom(
                                    bom_id=bom.id, product_id=str(res.product_id.id),
                                    line_qty=res.product_uom_qty, line_id=False,
                                    level=False)['total'] / res.product_uom_qty
                res.bom_price = price

Based on this field you can calculate Margin same as product cost

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Ảnh đại diện
Huỷ bỏ

help me with version 16

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 2 22
2925
2
thg 8 22
6288
2
thg 4 22
3435
3
thg 5 20
11663
3
thg 2 20
3113