Skip to Content
Menu
This question has been flagged
1 Reply
2510 Views

to change the state of record from website do we need to inherit the that state model.

imy controller.py file


from odoo import http , _
from odoo.http import request

class PortalAssignments (http.Controller):
_inherit = "op.assignment.sub.line"

@ http.route ( '/ assignment / submited' , type = 'http' , auth = 'public' , website = True ) 
def portal_submited_assignment_of_student ( self , ** kw):
assignment_ids = request.env [ 'op.assignment.sub .line ' ] .sudo (). create (kw)
return request.render ( "portal_assignments.portal_submited_assignment_of_student" , { ' assignment_ids' : assignment_ids})



#method for submit action method

@ api.multi 
def act_submit ( self ):
result = self .state = 'submit'
return result and result or False

xml code:

<button type = "object" name = "act_submit" string = "Submit" class = "btn btn-primary" >
SUBMIT
<span class = "fa fa-long-arrow-right" />
</button>


please help me to solve this iam not able to change the record state
Avatar
Discard
Best Answer

Hi,

Try this code,


@http.route( '/assignment/submited' , type = 'http' , auth = 'public' , website = True )
def portal_submited_assignment_of_student(self , ** kw):
assignment_ids = request.env['op.assignment.sub.line'].sudo().create(kw)
for assinement in assignment_ids:
assinement.state =
'submit'
return request.render("portal_assignments.portal_submited_assignment_of_student", {'assignment_ids': assignment_ids})


Thanks

Avatar
Discard
Author

thanks niyas raphy its working