Ensure that shipment work project is related to the same asset as the shipment

This commit is contained in:
Sergi Almacellas Abellana 2015-06-15 16:51:54 +02:00
parent dfd89759e9
commit c384bb1972
2 changed files with 15 additions and 3 deletions

View File

@ -7,6 +7,7 @@ from .work import *
def register():
Pool.register(
Project,
ShipmentWork,
ContractLine,
Contract,
module='asset_work_project', type_='model')

17
work.py
View File

@ -1,13 +1,12 @@
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
from collections import defaultdict
from decimal import Decimal
from trytond.model import fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
from trytond.pyson import Eval, If, Bool
__all___ = ['Project', 'ContractLine', 'Contract']
__all___ = ['Project', 'ShipmentWork', 'ContractLine', 'Contract']
__metaclass__ = PoolMeta
@ -75,6 +74,18 @@ class Project:
return res
class ShipmentWork:
__name__ = 'shipment.work'
@classmethod
def __setup__(cls):
super(ShipmentWork, cls).__setup__()
if 'asset' not in cls.project.depends:
cls.project.domain.append(If(Bool(Eval('asset')),
('asset', '=', Eval('asset')), ()))
cls.project.depends.append('asset')
class Contract:
__name__ = 'contract'