want to get currently logged in user id as default value in python file but when submit/save it is showing NULL value when querying thru psql. how i can get it, below are what i did, row saved but without current user's id in field user_id.
in python file:
user_id = fields.Many2one('res.partner', string="User",compute='_get_current_user')
@api.depends('name')
def _get_current_user(self):
for r in self:
r.user_id = self.env.user
created a web page as my view for data entry and controller file:
class QuickOrdersForm(http.Controller):
@http.route(['/web/quickorders/form'], type='http', auth="public", website=True)
def quickorders_form(self, **post):
return request.render("tests.web_quickorders_form", {})
@http.route(['/web/quickorders/form/submit'], type='http', auth="public", website=True)
# next controller with url for submitting data from the form#
def quickorders_form_submit(self, **post):
qorder = request.env['tests.quickorders'].create({
'name': post.get('name'),
'order_type': post.get('order_type')
})
vals = {
'qorder': qorder,
}
# inherited the model to pass the values to the model from the form#
return request.render("tests.web_quickorders_form_success", vals)