25 lines
752 B
Python
25 lines
752 B
Python
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
|
# this repository contains the full copyright notices and license terms.
|
|
from trytond.model import fields
|
|
from trytond.pool import PoolMeta
|
|
from decimal import Decimal
|
|
|
|
|
|
__all__ = ['BOM']
|
|
|
|
|
|
def round_dec(number):
|
|
return Decimal(number.quantize(Decimal('.01')))
|
|
|
|
|
|
class BOM(metaclass=PoolMeta):
|
|
__name__ = 'production.bom'
|
|
inputs_cost_price = fields.Function(fields.Numeric('Inputs Cost Price'),
|
|
'get_inputs_cost_price')
|
|
|
|
def get_inputs_cost_price(self, name):
|
|
total_cost = 0
|
|
for _in in self.inputs:
|
|
total_cost += round_dec(_in.product.cost_price * Decimal(_in.quantity))
|
|
return total_cost
|