Fix how customerAccountID is imported from CORE API

geez.

also optimize joinedloads when fetching Rattail member data for CORE
export
This commit is contained in:
Lance Edgar 2023-06-11 15:21:30 -05:00
parent 914fcbe192
commit 2ca9cd8f76
2 changed files with 12 additions and 6 deletions

View file

@ -106,8 +106,17 @@ class MemberImporter(FromRattail, corepos_importing.model.MemberImporter):
query = super().query()
model = self.model
# TODO: should joinedload for CustomerShopper.phones etc. too?
query = query.options(orm.joinedload(model.Customer.addresses))
query = query.options(orm.joinedload(model.Customer.members))\
.options(orm.joinedload(model.Customer._corepos))\
.options(orm.joinedload(model.Customer.addresses))\
.options(orm.joinedload(model.Customer.shoppers)\
.joinedload(model.CustomerShopper._corepos))\
.options(orm.joinedload(model.Customer.shoppers)\
.joinedload(model.CustomerShopper.person)\
.joinedload(model.Person.phones))\
.options(orm.joinedload(model.Customer.shoppers)\
.joinedload(model.CustomerShopper.person)\
.joinedload(model.Person.emails))
return query