[open-ils-commits] r8839 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb:
controllers/acq lib/acq templates/oils/default/acq/po
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Feb 27 20:09:26 EST 2008
Author: djfiander
Date: 2008-02-27 19:37:59 -0500 (Wed, 27 Feb 2008)
New Revision: 8839
Added:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/po/create.html
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/po.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/picklist.py
Log:
Initial support for creating POs from picklists and for deleting POs. This doesn't quite work yet.
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py 2008-02-26 21:08:54 UTC (rev 8838)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py 2008-02-28 00:37:59 UTC (rev 8839)
@@ -39,7 +39,7 @@
self.fund = ContextItem()
self.fund_id = ContextItem(cgi_name='acq.fi')
- self.fund_list = ContextItem()
+ self.fund_list = ContextItem(cgi_name='acq.fl')
self.fund_name = ContextItem(cgi_name='acq.fn')
self.fund_year = ContextItem(cgi_name='acq.fc')
self.fund_org = ContextItem(cgi_name='acq.fo')
@@ -64,7 +64,7 @@
self.fund_allocation_note = ContextItem(cgi_name='acq.fan')
self.provider = ContextItem()
- self.provider_id = ContextItem()
+ self.provider_id = ContextItem(cgi_name='acq.proid')
self.provider_list = ContextItem()
self.provider_name = ContextItem(cgi_name='acq.pn')
self.provider_currency_type = ContextItem(cgi_name='acq.pct')
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/po.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/po.py 2008-02-26 21:08:54 UTC (rev 8838)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/po.py 2008-02-28 00:37:59 UTC (rev 8839)
@@ -1,6 +1,6 @@
from oilsweb.lib.base import *
from oilsweb.lib.request import RequestMgr
-from oilsweb.lib.acq import provider_mgr;
+from oilsweb.lib.acq import provider_mgr
import oilsweb.lib.user
import osrf.net_obj
import oils.const
@@ -9,11 +9,9 @@
from oils.org import OrgUtil
import mx.DateTime.ISO
import oilsweb.lib.acq.po_manager
+from oilsweb.lib.acq.picklist import PicklistMgr
+from oilsweb.lib.acq.fund import FundMgr
-# open-ils.acq.purchase_order.retrieve "2f9697131c80e49fb9f2515781102f6a",
-# 8, {"flesh_lineitems":1,"clear_marc":1}
-
-
class PoController(BaseController):
# Render list of Purchase Orders
@@ -38,6 +36,48 @@
r.ctx.acq.provider.value = provider_mgr.retrieve(r, po_mgr.po.provider())
return r.render('acq/po/view_po.html')
+ # Create PO from contents of picklist
+ def create(self, **kwargs):
+ r = RequestMgr()
+ if not r.ctx.acq.picklist_source_id.value:
+ plmgr = PicklistMgr(r,
+ picklist_id=r.ctx.acq.picklist_source_id.value)
+ r.ctx.acq.picklist_list.value = plmgr.retrieve_list(r)
+
+ r.ctx.acq.fund_list.value = FundMgr(r).retrieve_org_funds()
+ provider_list = provider_mgr.list(r)
+ for p in provider_list:
+ p.owner(OrgUtil.get_org_unit(p.owner()))
+ r.ctx.acq.provider_list.value = provider_list
+ return r.render('acq/po/create.html')
+
+ po = osrf.net_obj.NetworkObject.acqpo()
+ po.owner(r.ctx.core.user.value.id())
+ po.provider(r.ctx.acq.provider_id.value)
+ po.default_fund(r.ctx.acq.fund_id.value)
+
+ po_id = ClientSession.atomic_request(oils.const.OILS_APP_ACQ,
+ 'open-ils.acq.purchase_order.create',
+ r.ctx.core.authtoken.value, po)
+ Event.parse_and_raise(po_id)
+
+ plmgr = oilsweb.lib.acq.picklist.PicklistMgr(r, picklist_id=r.ctx.acq.picklist_source_id.value)
+
+ plmgr.retrieve()
+ plmgr.retrieve_entries(idlist=1)
+
+ for pl_item in plmgr.picklist.entries():
+ po_lineitem = osrf.net_obj.NetworkObject.acqpoli()
+ po_lineitem.purchase_order(po_id)
+ po_lineitem_id = ClientSession.atomic_request(oils.const.OILS_APP_ACQ,
+ 'open-ils.acq.po_lineitem.create',
+ r.ctx.core.authtoken.value,
+ po_lineitem,
+ { 'picklist_entry': pl_item})
+ Event.parse_and_raise(po_lineitem_id)
+
+ return redirect_to(controller='acq/po', action='view', id=po_id)
+
# Render individual line item: list of detail info
def view_lineitem(self, **kwargs):
r = RequestMgr()
@@ -59,3 +99,10 @@
r.ctx.acq.po.value = po_mgr.po
return r.render('acq/po/view_lineitem.html')
+
+ def delete(self, **kwargs):
+ r = RequestMgr()
+ ClientSession.atomic_request(oils.const.OILS_APP_ACQ,
+ 'open-ils.acq.purchase_order.delete',
+ r.ctx.core.authtoken.value, kwargs['id'])
+ return r.render('acq/po/list')
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/picklist.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/picklist.py 2008-02-26 21:08:54 UTC (rev 8838)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/lib/acq/picklist.py 2008-02-28 00:37:59 UTC (rev 8839)
@@ -13,7 +13,7 @@
def retrieve(self):
picklist = self.ses.request(
'open-ils.acq.picklist.retrieve',
- self.request_mgr.ctx.core.authtoken.value, self.id, {'flesh_entry_count':1}).recv().content()
+ self.request_mgr.ctx.core.authtoken.value, self.id, {'flesh_entry_count':1, 'flesh_username':1}).recv().content()
oils.event.Event.parse_and_raise(picklist)
self.picklist = picklist
@@ -54,6 +54,7 @@
{
"offset" : kwargs.get('offset'),
"limit" : kwargs.get('limit'),
+ "idlist" : kwargs.get('idlist'),
"flesh" : 1,
"clear_marc" : 1
}
Added: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/po/create.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/po/create.html (rev 0)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/po/create.html 2008-02-28 00:37:59 UTC (rev 8839)
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+<!-- vim:set filetype=mako: -->
+<%inherit file='../base.html'/>
+<%def name="page_title()">${_('Create Purchase Order')}</%def>
+<%def name="block_content()">
+<form action="${c.oils.acq.prefix.value}/po/create" method="POST">
+ <select name="${c.oils.acq.picklist_source_id.cgi_name}">
+ <option selected='selected' value="">${_('-- Select A Picklist --')}</option>
+ % for pl in c.oils.acq.picklist_list.value:
+ <option value='${pl.id()}'>${pl.name()}</option>
+ % endfor
+ </select>
+ <select name="${c.oils.acq.fund_id.cgi_name}">
+ <option selected='selected' value="">${_('-- Default Fund --')}</option>
+ % for fund in c.oils.acq.fund_list.value:
+ <option value="${fund.id()}">${fund.name()}</option>
+ % endfor
+ </select>
+ <select name="${c.oils.acq.provider_id.cgi_name}">
+ <option selected='selected' value="">${_('-- Select A Provider --')}</option>
+ % for provider in c.oils.acq.provider_list.value:
+ <option value="${provider.id()}">${provider.name()}</option>
+ % endfor
+ </select>
+ <input type="submit" value="Create">
+</form>
+</%def>
More information about the open-ils-commits
mailing list