Make supplier_id, receiver_id optional for ProofReuse, fixes #21

This commit is contained in:
yiorgos marinellis 2020-03-27 11:48:16 +01:00
parent edf2e39fc7
commit bc69d194f4
2 changed files with 7 additions and 5 deletions

View File

@ -137,12 +137,14 @@ class ProofReuse(JoinedTableMixin, Proof):
id_receipt = Column(CIText(), default='', nullable=False)
supplier_id = db.Column(UUID(as_uuid=True),
db.ForeignKey(User.id),
nullable=False,
default=lambda: g.user.id)
# nullable=False,
# default=lambda: g.user.id)
nullable=True)
supplier = db.relationship(User, primaryjoin=lambda: ProofReuse.supplier_id == User.id)
receiver_id = db.Column(UUID(as_uuid=True),
db.ForeignKey(User.id),
nullable=False)
# nullable=False)
nullable=True)
receiver = db.relationship(User, primaryjoin=lambda: ProofReuse.receiver_id == User.id)
price = Column(db.Integer)

View File

@ -57,8 +57,8 @@ class ProofReuse(Proof):
__doc__ = m.ProofReuse.__doc__
receiver_segment = String(default='', data_key='receiverSegment', required=True)
id_receipt = String(default='', data_key='idReceipt', required=True)
supplier_id = UUID(load_only=True, required=True, data_key='supplierID')
receiver_id = UUID(load_only=True, required=True, data_key='receiverID')
supplier_id = UUID(load_only=True, required=False, data_key='supplierID')
receiver_id = UUID(load_only=True, required=False, data_key='receiverID')
price = Integer(required=True)