order id handling via shop
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3295 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
		
							parent
							
								
									2a7acff23b
								
							
						
					
					
						commit
						0efaa8479d
					
				
					 3 changed files with 21 additions and 2 deletions
				
			
		|  | @ -115,7 +115,8 @@ Orders | ||||||
| 
 | 
 | ||||||
| The items in a shopping cart may be included in an order. | The items in a shopping cart may be included in an order. | ||||||
| 
 | 
 | ||||||
|   >>> ord001 = manager.orders.create(u'001', shop=shop1, customer=c001) |   >>> orderId = shop1.getNewOrderId() | ||||||
|  |   >>> ord001 = manager.orders.create(orderId, shop=shop1, customer=c001) | ||||||
| 
 | 
 | ||||||
|   >>> for item in orderItems.getCart(c001): |   >>> for item in orderItems.getCart(c001): | ||||||
|   ...     item.setOrder(ord001) |   ...     item.setOrder(ord001) | ||||||
|  |  | ||||||
|  | @ -76,6 +76,13 @@ class IShop(Interface): | ||||||
|             description=_(u'A medium-length description.'), |             description=_(u'A medium-length description.'), | ||||||
|             default=u'', |             default=u'', | ||||||
|             required=False) |             required=False) | ||||||
|  |     orderNumber = schema.Int( | ||||||
|  |             title=_(u'Order Number'), | ||||||
|  |             description=_(u'The number used for the order identifier of ' | ||||||
|  |                           u'last order created. This will in turn be used ' | ||||||
|  |                           u'for creating the next order identifier.'), | ||||||
|  |             default=0, | ||||||
|  |             required=False) | ||||||
| 
 | 
 | ||||||
|     products = Attribute(u'The products available in this shop.') |     products = Attribute(u'The products available in this shop.') | ||||||
|     categories = Attribute(u'The product categories provided by this shop.') |     categories = Attribute(u'The product categories provided by this shop.') | ||||||
|  | @ -85,6 +92,10 @@ class IShop(Interface): | ||||||
|                     u'this shop.') |                     u'this shop.') | ||||||
|     customers = Attribute(u'The customers registered for this shop.') |     customers = Attribute(u'The customers registered for this shop.') | ||||||
| 
 | 
 | ||||||
|  |     def getNewOrderId(): | ||||||
|  |         """ Create a new order identifier. | ||||||
|  |         """ | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| # manufacturers and suppliers | # manufacturers and suppliers | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| # | # | ||||||
| #  Copyright (c) 2008 Helmut Merz helmutm@cy55.de | #  Copyright (c) 2009 Helmut Merz helmutm@cy55.de | ||||||
| # | # | ||||||
| #  This program is free software; you can redistribute it and/or modify | #  This program is free software; you can redistribute it and/or modify | ||||||
| #  it under the terms of the GNU General Public License as published by | #  it under the terms of the GNU General Public License as published by | ||||||
|  | @ -39,3 +39,10 @@ class Shop(BaseObject): | ||||||
|         self.title = title or u'Shop' |         self.title = title or u'Shop' | ||||||
|         self.products = self.collection(self, 'shops') |         self.products = self.collection(self, 'shops') | ||||||
|         self.customers = self.collection(self, 'shops') |         self.customers = self.collection(self, 'shops') | ||||||
|  |         self.orderNumber = 0 | ||||||
|  | 
 | ||||||
|  |     def getNewOrderId(self): | ||||||
|  |         last = self.orderNumber or 0 | ||||||
|  |         num = last + 1 | ||||||
|  |         self.orderNumber = num | ||||||
|  |         return '%05i' % num | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 helmutm
						helmutm