Traceback
1.
2.
3.
4.
5.
6.
7.
Traceback (most recent call last):
File "/home/act/web2py/gluon/main.py", line 505, in wsgibase
request.body.close()
File "/usr/local/lib/python2.7/tempfile.py", line 431, in close
self.unlink(self.name)
OSError: [Errno 2] No such file or directory: '/tmp/tmpGdGmPE'
Error snapshot
<type 'exceptions.OSError'>([Errno 2] No such file or directory: '/tmp/tmpGdGmPE')
@auth.requires_login()
def add_custom():
#check if there is an offer selected
# if not session.quote or not session.quote.number:
# session.flash = T('Please select an offer first')
# redirect(URL('default', 'offer_landing'))
try:
offerId = request.args[0]
except IndexError:
offerId = 0
offerDetails = offer.authorise(offerId)
pagetitle = H3(T('Custom Product'))
buttongroup = [btn.back()]
try:
record = db.custom_product[request.args[1]] or None
except [IndexError, KeyError, TypeError]:
record = None
if session.custom_copy:
db.custom_product.productname.default = session.custom_copy.productname
db.custom_product.description.default = session.custom_copy.description
db.custom_product.purchasecost.default = session.custom_copy.purchasecost
db.custom_product.monthlycost.default = session.custom_copy.monthlycost
#db.custom_product.smallimage.default = session.custom_copy.smallimage
session.custom_copy = None
db.custom_product.created_on.readable = False
db.custom_product.updated_on.readable = False
form = SQLFORM(db.custom_product, record, showid = False)
if form.process().accepted:
#do this for insert but not update
if not record:
# need to get the max priorites from the offer table
pp = mp = None
# offerDetails = db.offer[session.quote.number]
# increment whichever needs to be used and save it to the offer table
if form.vars.purchasecost:
if offerDetails.offer.maxpurchasepriority:
offerDetails.offer.maxpurchasepriority += 1
else:
offerDetails.offer.maxpurchasepriority = 1
pp = offerDetails.offer.maxpurchasepriority
if form.vars.monthlycost or (not form.vars.purchasecost and not form.vars.monthlycost):
if offerDetails.offer.maxmonthlypriority:
offerDetails.offer.maxmonthlypriority += 1
else:
offerDetails.offer.maxmonthlypriority = 1
mp = offerDetails.offer.maxmonthlypriority
offerDetails.offer.update_record()
# insert record into product_offer_item
db.product_offer_item.insert(
offer_id = offerDetails.offer.id,
custom_pid = form.vars.id,
quantity = 1,
purchasepriority = pp,
monthlypriority = mp,
)
else:
# only do this for updates
# check if a price change also needs a priority change
poiRecord = record.product_offer_item.select().first()
pp = copy.copy(poiRecord.purchasepriority)
mp = copy.copy(poiRecord.monthlypriority)
#poi_set = db(db.product_offer_item.custom_pid == poiRecord.id)
if pp and (not form.vars.purchasecost > 0):
poiRecord.update_record(purchasepriority = 0)
if not pp and (form.vars.purchasecost > 0):
poiRecord.update_record(purchasepriority = 99.5)
if mp and (form.vars.purchasecost > 0 and not form.vars.monthlycost > 0):
poiRecord.update_record(monthlypriority = 0)
if not mp and\
((not form.vars.purchasecost > 0 and not form.vars.monthlycost > 0) or\
not form.vars.purchasecost > 0 and form.vars.monthlycost > 0):
poiRecord.update_record(monthlypriority = 99.5)
offer.position_check(offerDetails.offer.id)
session.flash = T('Success')
redirect(btn.EditOffer(offerDetails.offer.id,
dict(custId = offerDetails.customer.id)).url)
elif form.errors:
response.flash = T('Errors in form')
else:
pass
status = roo.status(offerDetails) # <- Moved this line from the top to down here
response.view = 'core.html'
return dict(
pagetitle = pagetitle,
pagecontent = form,
buttongroup = buttongroup,
status = status,
)