Пример #1
0
 def order_item_json(self):
     purchase_order_id = self.request.matchdict.get('purchase_order_id')
     order_item_id = self.request.matchdict.get('order_item_id')
     porder = PurchaseOrder.load(purchase_order_id)
     self.forbid_if(not porder)
     poi = PurchaseOrderItem.load(order_item_id)
     self.forbid_if(not poi or poi.purchase_order != porder)
     return json.dumps({'order_item_id':str(poi.order_item_id), 
                        'note':poi.note,
                        'quantity':poi.quantity, 
                        'unit_cost':poi.unit_cost,
                        'prod_name':poi.product.name})
Пример #2
0
 def delete_purchase_order_item(self):
     purchase_order_id = self.request.matchdict.get('purchase_order_id')
     order_item_id = self.request.matchdict.get('order_item_id')
     porder = PurchaseOrder.load(purchase_order_id)
     self.forbid_if(not porder)
     poi = PurchaseOrderItem.load(order_item_id)
     self.forbid_if(not poi or poi.purchase_order != porder)
     prod = poi.product
     poi.delete()
     Status.add(None, porder, Status.find_event(self.enterprise_id, porder, 'MODIFIED'),
                'Purchase Order %s. "%s" removed.' % ('MODIFIED', prod.name),
                self.request.ctx.user)
     poi.flush()
     return 'True'
Пример #3
0
 def complete_item(self):
     purchase_order_id = self.request.matchdict.get('purchase_order_id')
     order_item_id = self.request.matchdict.get('order_item_id')
     porder = PurchaseOrder.load(purchase_order_id)
     self.forbid_if(not porder)
     poi = PurchaseOrderItem.load(order_item_id)
     self.forbid_if(not poi or poi.purchase_order != porder or poi.complete_dt)
     poi.complete_dt = util.today()
     poi.save()
     poi.flush()
     InventoryJournal.create_new(poi.product, 'Item Receipt', poi.quantity)
     Status.add(None, porder, Status.find_event(self.enterprise_id, porder, 'COMPLETED'),
                'Purchase Order Item "%s" Completed' % poi.product.name,
                self.request.ctx.user) 
     return 'True'
Пример #4
0
 def save_purchase_order_item(self):
     purchase_order_id = self.request.matchdict.get('purchase_order_id')
     self.forbid_if(not 'product_id' in self.request.GET or not self.request.GET.get('product_id'))
     poi = PurchaseOrderItem.load(self.request.POST.get('order_item_id'))
     if not poi:
         poi = PurchaseOrderItem()
         poi.purchase_order_id = purchase_order_id
     poi.bind(self.request.POST)
     poi.product_id = self.request.GET.get('product_id')
     poi.note = self.request.POST.get('order_note')
     poi.save()
     poi.flush()
     porder = poi.purchase_order
     Status.add(None, porder, Status.find_event(self.enterprise_id, porder, 'MODIFIED'),
                'Purchase Order %s. "%s" added.' % ('MODIFIED', poi.product.name),
                self.request.ctx.user)
     self.db_flush()
     return '{"id": "%s"}' % poi.order_item_id