i have added a button wizard in purchase order form that contain reject button and special cancel button.
as soon as i click that button , the wizard form show up. Then after i fill every field in that wizard i have to click the reject button to execute the method. but my method doesn't return anything. did i put the wrong return ?
here's the code :
class reason_reject_approval(osv.osv_memory):
_name = "reason.reject.approval"
_columns = {
'reason':fields.text('Reason')
}
def wtc_reject_approval(self, cr, uid, ids, context=None):
val = self.browse(cr, uid, ids, context=context)
user = self.pool.get("res.users").browse(cr, uid, uid)['groups_id']
line = self.pool.get("purchase.order").browse(cr,uid,ids,context=context)
for x in line.app_line :
for y in user:
if y == x.group_id :
for z in line.app_line :
z.write(cr,uid,z.id,{
'reason':val.reason,
'value':line.amount_total,
'sts':'3',
'pelaksana':uid,
'tanggal':datetime.today()
})
self.pool.get("purchase.order").action_cancel(cr, uid,ids)
self.pool.get("purchase.order").write(cr, uid, ids, {'approval_state':'r'})
return True
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
do you know how to solve it ? thanks.
@ajeng what value you want to return and how will you use that returned value? what is your exact purpose? Also in the getting the browse record for 'purchase.order' you have directly use 'ids' which is wrong you should have used context.get('active_id')
in approval , there are 2 condition ,, approve and reject . if the reason is reject there must be a reason. I want that reason to show up in purchase order form .
previously i have added one2many field on purchase order called app_line it contain many fields , such as reason, value , sts, pelaksana, tanggal, etc. i have added two button approve and reject , reject is a wizard that i mean.
@Ajeng what have you used on the wizard to get the reason from the user? Is it just a text box? and if yes where exactly you want that value to be saved? If possible try posting some images of your screen so can better idea.
if you don't mind can i know your email ? i will sent directly by email
@emipro this is the link for what i mean https://berbagiopenerp.wordpress.com/2014/12/25/approval-purchase-order/