Join the Person model for Customers grid differently based on config
This commit is contained in:
parent
bf1726a52b
commit
5a03f5c23e
|
@ -128,9 +128,19 @@ class CustomerView(MasterView):
|
||||||
|
|
||||||
def query(self, session):
|
def query(self, session):
|
||||||
query = super().query(session)
|
query = super().query(session)
|
||||||
|
app = self.get_rattail_app()
|
||||||
model = self.model
|
model = self.model
|
||||||
return query.outerjoin(model.Person,
|
if app.get_clientele_handler().should_use_legacy_people():
|
||||||
|
query = query.outerjoin(model.CustomerPerson,
|
||||||
|
sa.and_(
|
||||||
|
model.CustomerPerson.customer_uuid == model.Customer.uuid,
|
||||||
|
model.CustomerPerson.ordinal == 1))\
|
||||||
|
.outerjoin(model.Person,
|
||||||
|
model.Person.uuid == model.CustomerPerson.person_uuid)
|
||||||
|
else:
|
||||||
|
query = query.outerjoin(model.Person,
|
||||||
model.Person.uuid == model.Customer.account_holder_uuid)
|
model.Person.uuid == model.Customer.account_holder_uuid)
|
||||||
|
return query
|
||||||
|
|
||||||
def configure_grid(self, g):
|
def configure_grid(self, g):
|
||||||
super().configure_grid(g)
|
super().configure_grid(g)
|
||||||
|
|
Loading…
Reference in a new issue