odoo/ext/custom-addons/dp_rest_to_rpc/controllers/main.py

76 lines
3.0 KiB
Python

# -*- coding: utf-8 -*-
##############################################################################
#
# datenpol gmbh
# Copyright (C) 2013-TODAY datenpol gmbh (<http://www.datenpol.at/>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from odoo import http
from odoo.http import request
class MyController(http.Controller):
@http.route('/portal_create_partner', type='json', auth='none', methods=['POST'])
def handle_portal_create_partner(self, **post):
values = request.jsonrequest
partner_obj = request.env['res.partner'].sudo()
try:
partner_id = partner_obj.portal_create_partner(values)
except Exception as e:
return e.args[0]
return partner_id
@http.route('/pg_create_company', type='json', auth='none', methods=['POST'])
def handle_pg_create_company(self, **post):
values = request.jsonrequest
partner_obj = request.env['res.partner'].sudo()
try:
partner_id = partner_obj.pg_create_company(values)
except Exception as e:
return e.args[0]
return partner_id
@http.route('/pg_get_orders', type='json', auth='none', methods=['POST'])
def handle_pg_get_orders(self, **post):
values = request.jsonrequest
sale_order_obj = request.env['sale.order'].sudo()
try:
sale_order_id = sale_order_obj.pg_get_orders(values['line'], values['state'], values['limit'])
except Exception as e:
return e.args[0]
return sale_order_id
@http.route('/create_product', type='json', auth='none', methods=['POST'])
def handle_create_product(self, **post):
values = request.jsonrequest
product_obj = request.env['product.template'].sudo()
try:
product_id = product_obj.create_product(values)
except Exception as e:
return e.args[0]
return product_id
@http.route('/pg_create_quotation', type='json', auth='none', methods=['POST'])
def handle_pg_create_quotation(self, **post):
values = request.jsonrequest
sale_order_obj = request.env['sale.order'].sudo()
try:
sale_order_id = sale_order_obj.pg_create_quotation(values)
except Exception as e:
return e.args[0]
return sale_order_id