Apply 0 Lot : 0-1 Deliverynote relationship

This commit is contained in:
yiorgos marinellis 2020-03-04 18:49:55 +01:00
parent f5b2f3c2f6
commit de8af45065
2 changed files with 5 additions and 6 deletions

View File

@ -49,11 +49,10 @@ class Deliverynote(Thing):
lot_id = db.Column(UUID(as_uuid=True), lot_id = db.Column(UUID(as_uuid=True),
db.ForeignKey(Lot.id), db.ForeignKey(Lot.id),
nullable=False) nullable=False)
lots = db.relationship(Lot, lot = db.relationship(Lot,
backref=db.backref('deliverynotes', lazy=True, collection_class=set), backref=db.backref('deliverynote', uselist=False, lazy=True),
lazy=True, lazy=True,
primaryjoin=Lot.id == lot_id, primaryjoin=Lot.id == lot_id)
collection_class=set)
def __init__(self, document_id: str, deposit: str, date, def __init__(self, document_id: str, deposit: str, date,
supplier_email: str, supplier_email: str,

View File

@ -25,4 +25,4 @@ class Lot(Thing):
owner_address = SanitizedStr(validate=f.validate.Length(max=42)) owner_address = SanitizedStr(validate=f.validate.Length(max=42))
transfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment) transfer_state = EnumField(TransferState, description=m.Lot.transfer_state.comment)
receiver_address = SanitizedStr(validate=f.validate.Length(max=42)) receiver_address = SanitizedStr(validate=f.validate.Length(max=42))
deliverynotes = NestedOn(s_deliverynote.Deliverynote, many=True, dump_only=True) deliverynote = NestedOn(s_deliverynote.Deliverynote, dump_only=True)