Mercurial > hgweb > health
changeset 2008:f1707c2c2130
health : bug #45350 - check for mother / father in the birth certificate before returning the ID
| author | Luis Falcon <falcon@gnu.org> |
|---|---|
| date | Wed, 22 Jul 2015 15:58:59 +0100 |
| parents | 9514e91fcc23 |
| children | 93b6f65028ce |
| files | tryton/health/health.py |
| diffstat | 1 files changed, 7 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health/health.py +++ b/tryton/health/health.py @@ -318,35 +318,13 @@ fields.Many2One('party.party','Father', help="Father from the Birth Certificate"),'get_father') - @classmethod - def get_mother(cls, parties, name): - cursor = Transaction().cursor - BD = Pool().get('gnuhealth.birth_certificate') - bd = BD.__table__() - ids = map(int, parties) - result = dict.fromkeys(ids, None) - for sub_ids in grouped_slice(ids): - clause_ids = reduce_ids(bd.name, sub_ids) - query = bd.select(bd.name, bd.mother, - where = (bd.mother != None) & clause_ids) - cursor.execute(*query) - result.update(cursor.fetchall()) - return result - - @classmethod - def get_father(cls, parties, name): - cursor = Transaction().cursor - BD = Pool().get('gnuhealth.birth_certificate') - bd = BD.__table__() - ids = map(int, parties) - result = dict.fromkeys(ids, None) - for sub_ids in grouped_slice(ids): - clause_ids = reduce_ids(bd.name, sub_ids) - query = bd.select(bd.name, bd.father, - where = (bd.father != None) & clause_ids) - cursor.execute(*query) - result.update(cursor.fetchall()) - return result + def get_mother(self, name): + if (self.birth_certificate and self.birth_certificate.mother): + return self.birth_certificate.mother.id + + def get_father(self, name): + if (self.birth_certificate and self.birth_certificate.father): + return self.birth_certificate.father.id @staticmethod def default_activation_date():
