Change the way that the cost of operations are calculated when have

subcontracted product. If the operation have a purchase line us it's
cost, if not, but have a subcontract product use it cost, and if has
nothing us the default way.
This commit is contained in:
Bernat Brunet 2022-10-26 01:17:54 +02:00
parent 7c179ed332
commit 74226f9b0b
1 changed files with 11 additions and 2 deletions

View File

@ -462,9 +462,18 @@ class OperationSubcontrat(metaclass=PoolMeta):
cls.save(to_save)
def get_cost(self, name):
cost = super().get_cost(name)
pool = Pool()
Uom = pool.get('product.uom')
if self.purchase_request and self.purchase_request.purchase_line:
cost += self.purchase_request.purchase_line.amount
cost = self.purchase_request.purchase_line.amount
elif self.subcontracted_product:
quantity = Uom.compute_qty(self.uom, self.total_quantity,
self.subcontracted_product.default_uom)
cost = (Decimal(str(quantity)) *
self.subcontracted_product.cost_price)
else:
cost = super().get_cost(name)
return cost
@classmethod