Must pass rows to make_new_order()
for custorder batch
also allow passing `new_order_id` if `batch.id` is not wanted for order
This commit is contained in:
parent
f81ddb113a
commit
f81da39fd2
|
@ -886,7 +886,7 @@ class CustomerOrderBatchHandler(BatchHandler):
|
||||||
customer record. Override as needed.
|
customer record. Override as needed.
|
||||||
"""
|
"""
|
||||||
rows = batch.active_rows()
|
rows = batch.active_rows()
|
||||||
order = self.make_new_order(batch, user=user, progress=progress, **kwargs)
|
order = self.make_new_order(batch, rows, user=user, progress=progress, **kwargs)
|
||||||
self.update_contact_info(batch, user)
|
self.update_contact_info(batch, user)
|
||||||
self.mark_pending_things_ready(batch, rows)
|
self.mark_pending_things_ready(batch, rows)
|
||||||
return order
|
return order
|
||||||
|
@ -939,7 +939,7 @@ class CustomerOrderBatchHandler(BatchHandler):
|
||||||
'email_address': batch.email_address,
|
'email_address': batch.email_address,
|
||||||
})
|
})
|
||||||
|
|
||||||
def make_new_order(self, batch, user=None, progress=None, **kwargs):
|
def make_new_order(self, batch, rows, user=None, progress=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Create and return a new rattail Customer Order based on the
|
Create and return a new rattail Customer Order based on the
|
||||||
batch contents.
|
batch contents.
|
||||||
|
@ -961,6 +961,10 @@ class CustomerOrderBatchHandler(BatchHandler):
|
||||||
for field in batch_fields:
|
for field in batch_fields:
|
||||||
setattr(order, field, getattr(batch, field))
|
setattr(order, field, getattr(batch, field))
|
||||||
|
|
||||||
|
new_order_id = kwargs.get('new_order_id')
|
||||||
|
if new_order_id:
|
||||||
|
order.id = new_order_id
|
||||||
|
|
||||||
session = self.app.get_session(batch)
|
session = self.app.get_session(batch)
|
||||||
session.add(order)
|
session.add(order)
|
||||||
session.flush()
|
session.flush()
|
||||||
|
@ -999,7 +1003,7 @@ class CustomerOrderBatchHandler(BatchHandler):
|
||||||
# set initial status and attach events
|
# set initial status and attach events
|
||||||
self.set_initial_item_status(item, user)
|
self.set_initial_item_status(item, user)
|
||||||
|
|
||||||
self.progress_loop(convert, batch.active_rows(), progress,
|
self.progress_loop(convert, rows, progress,
|
||||||
message="Converting batch rows to order items")
|
message="Converting batch rows to order items")
|
||||||
|
|
||||||
session.flush()
|
session.flush()
|
||||||
|
|
Loading…
Reference in a new issue