parent
e122abcfda
commit
7c179ed332
13
operation.py
13
operation.py
|
@ -6,7 +6,7 @@ from trytond.pyson import Eval, If, Id, Bool
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from trytond.exceptions import UserWarning, UserError
|
from trytond.exceptions import UserWarning, UserError
|
||||||
|
from trytond.modules.product import round_price
|
||||||
|
|
||||||
__all__ = ['Operation', 'OperationTracking', 'Production']
|
__all__ = ['Operation', 'OperationTracking', 'Production']
|
||||||
|
|
||||||
|
@ -323,8 +323,6 @@ class Production(metaclass=PoolMeta):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Config = pool.get('production.configuration')
|
Config = pool.get('production.configuration')
|
||||||
Operation = pool.get('production.operation')
|
Operation = pool.get('production.operation')
|
||||||
Template = pool.get('product.template')
|
|
||||||
Product = pool.get('product.product')
|
|
||||||
Warning = pool.get('res.user.warning')
|
Warning = pool.get('res.user.warning')
|
||||||
|
|
||||||
config = Config(1)
|
config = Config(1)
|
||||||
|
@ -348,11 +346,6 @@ class Production(metaclass=PoolMeta):
|
||||||
production=operation.production.rec_name,
|
production=operation.production.rec_name,
|
||||||
operation=operation.rec_name))
|
operation=operation.rec_name))
|
||||||
|
|
||||||
if hasattr(Product, 'cost_price'):
|
|
||||||
digits = Product.cost_price.digits
|
|
||||||
else:
|
|
||||||
digits = Template.cost_price.digits
|
|
||||||
|
|
||||||
for production in productions:
|
for production in productions:
|
||||||
operation_cost = sum(o.cost for o in production.operations)
|
operation_cost = sum(o.cost for o in production.operations)
|
||||||
if operation_cost == Decimal('0.0'):
|
if operation_cost == Decimal('0.0'):
|
||||||
|
@ -360,8 +353,7 @@ class Production(metaclass=PoolMeta):
|
||||||
total_quantity = Decimal(str(sum(o.quantity for o in
|
total_quantity = Decimal(str(sum(o.quantity for o in
|
||||||
production.outputs)))
|
production.outputs)))
|
||||||
if total_quantity:
|
if total_quantity:
|
||||||
added_unit_price = Decimal(operation_cost / total_quantity
|
added_unit_price = round_price(operation_cost / total_quantity)
|
||||||
).quantize(Decimal(str(10 ** -digits[1])))
|
|
||||||
for output in production.outputs:
|
for output in production.outputs:
|
||||||
output.unit_price += added_unit_price
|
output.unit_price += added_unit_price
|
||||||
output.save()
|
output.save()
|
||||||
|
@ -430,7 +422,6 @@ class OperationSubcontrat(metaclass=PoolMeta):
|
||||||
def _get_purchase_request(self):
|
def _get_purchase_request(self):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Request = pool.get('purchase.request')
|
Request = pool.get('purchase.request')
|
||||||
Uom = pool.get('product.uom')
|
|
||||||
|
|
||||||
product = self.subcontracted_product
|
product = self.subcontracted_product
|
||||||
uom = product.purchase_uom
|
uom = product.purchase_uom
|
||||||
|
|
Loading…
Reference in New Issue