Hi,
I created one user under adminstrator. Now i want to conform a sale order from user. After logged on from user, Press a confirm button following error shown.
Scenario :, User should not approve a sale order value greater than 2.5 lakhs. For that i inherit a class, sale.config.setting , Code for your reference
class sale_config(osv.osv_memory):
_inherit = 'sale.config.settings'
_columns = {
'quote_limit': fields.float('Sales Person limit for raising Sale order',
digits=(16,2),
help="To allow your salesman to make invoices for sales order lines amount for limit."),
}
sale_config()
class quote_approve_limit(osv.osv): _name= 'quote.approve.limit' _description =' Change the limit of quotation '
_columns = {
'name' : fields.char('Description for Setting Quotation limit', size=128),
'value' : fields.float('Limit', digits=(16,2)),
}
quote_approve_limit()
Validation in sale.py .
class sale_order(osv.osv):
""" Inherits Qutation insert field to validity date """
_inherit = 'sale.order'
def action_button_confirm(self, cr, uid, ids, context=None):
a = self.browse(cr,uid, ids)[0]
l_obj=self.pool.get('quote.approve.limit').search(cr,uid,[('id','=', 1)])
l2= self.pool.get('quote.approve.limit').browse(cr,uid,l_obj[0])
if a.amount_total > l2.value and uid != 1:
raise osv.except_osv(_('Warning!'),_('You cannot confirm a sales order which has greater than 2.5 Lakhs. Need a approval from Higher Authority'))
else:
assert len(ids) == 1, 'This option should only be used for a single id at a time.'
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'sale.order', ids[0], 'order_confirm', cr)
return True
Executed well, When i logged in as user and try to press confirm button it shows following error: Unable to confirm a sale order....
Access Denied Sorry, you are not allowed to access this document. Please contact your system administrator if you think this is an error. (Document model: quote.approve.limit)
Any solution for that error let me know.. Thanks in advance...