blob: 0990a1a00315b9fa069c0dd7e7cac822b06c064c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
from .. import controller
from odoo import http
from odoo.http import request
class Voucher(controller.Controller):
prefix = '/api/v1/'
@http.route(prefix + 'voucher', auth='public', methods=['GET', 'OPTIONS'])
@controller.Controller.must_authorized()
def get_vouchers(self, **kw):
code = kw.get('code')
visibility = 'public'
parameter = []
if code:
visibility = 'private'
parameter += [('code', '=', code)]
parameter += [('visibility', '=', visibility)]
vouchers = request.env['voucher'].get_active_voucher(parameter)
data = vouchers.res_format()
return self.response(data)
|