parent
6420dce7c1
commit
417a60b989
19
operation.py
19
operation.py
|
@ -2,7 +2,7 @@ from decimal import Decimal
|
||||||
from trytond.model import (fields, ModelSQL, ModelView, Workflow,
|
from trytond.model import (fields, ModelSQL, ModelView, Workflow,
|
||||||
sequence_ordered)
|
sequence_ordered)
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.pyson import Eval, If, Id, Bool, And
|
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
|
||||||
|
@ -293,7 +293,6 @@ class Production(metaclass=PoolMeta):
|
||||||
|
|
||||||
@fields.depends('route', 'operations')
|
@fields.depends('route', 'operations')
|
||||||
def on_change_route(self):
|
def on_change_route(self):
|
||||||
Operation = Pool().get('production.operation')
|
|
||||||
self.operations = None
|
self.operations = None
|
||||||
operations = []
|
operations = []
|
||||||
if self.route:
|
if self.route:
|
||||||
|
@ -456,7 +455,6 @@ class OperationSubcontrat(metaclass=PoolMeta):
|
||||||
@classmethod
|
@classmethod
|
||||||
@ModelView.button
|
@ModelView.button
|
||||||
def create_purchase_request(cls, operations):
|
def create_purchase_request(cls, operations):
|
||||||
pool = Pool()
|
|
||||||
to_save = []
|
to_save = []
|
||||||
for operation in operations:
|
for operation in operations:
|
||||||
if not operation.subcontracted_product:
|
if not operation.subcontracted_product:
|
||||||
|
@ -467,7 +465,6 @@ class OperationSubcontrat(metaclass=PoolMeta):
|
||||||
cls.save(to_save)
|
cls.save(to_save)
|
||||||
|
|
||||||
def get_cost(self, name):
|
def get_cost(self, name):
|
||||||
pool = Pool()
|
|
||||||
cost = super().get_cost(name)
|
cost = super().get_cost(name)
|
||||||
if self.purchase_request and self.purchase_request.purchase_line:
|
if self.purchase_request and self.purchase_request.purchase_line:
|
||||||
cost += self.purchase_request.purchase_line.amount
|
cost += self.purchase_request.purchase_line.amount
|
||||||
|
@ -552,8 +549,18 @@ class PurchaseLine(metaclass=PoolMeta):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_origin(cls):
|
def _get_origin(cls):
|
||||||
'Return list of Model names for origin Reference'
|
'Return list of Model names for origin Reference'
|
||||||
return [cls.__name__, 'production.operation', 'production',
|
origins = [cls.__name__, 'production.operation', 'production']
|
||||||
'stock.order_point', 'purchase.request']
|
try:
|
||||||
|
Pool().get('stock.order_point')
|
||||||
|
origins += ['stock.order_point']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
Pool().get('purchase.request')
|
||||||
|
origins += ['purchase.request']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
return origins
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_origin(cls):
|
def get_origin(cls):
|
||||||
|
|
Loading…
Reference in New Issue