Let user "add past product" when making new custorder

This commit is contained in:
Lance Edgar 2021-11-06 20:00:54 -05:00
parent ddb05afe6b
commit 5d875bc731
2 changed files with 188 additions and 16 deletions

View file

@ -263,6 +263,7 @@ class CustomerOrderView(MasterView):
'get_customer_info',
# 'set_customer_data',
'get_product_info',
'get_past_items',
'add_item',
'update_item',
'delete_item',
@ -568,6 +569,21 @@ class CustomerOrderView(MasterView):
info['url'] = self.request.route_url('products.view', uuid=info['uuid'])
return info
def get_past_items(self, batch, data):
past_products = self.handler.get_past_products(batch)
past_items = []
for product in past_products:
try:
item = self.handler.get_product_info(batch, product)
except:
# nb. handler may raise error if product is "unsupported"
pass
else:
past_items.append(item)
return {'past_items': past_items}
def normalize_batch(self, batch):
return {
'uuid': batch.uuid,