Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a8184bd

Browse filesBrowse files
committed
add ACTION api
1 parent 407c8af commit a8184bd
Copy full SHA for a8184bd

File tree

Expand file treeCollapse file tree

1 file changed

+21
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+21
-1
lines changed

‎controllers/controllers.py

Copy file name to clipboardExpand all lines: controllers/controllers.py
+21-1Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
# Codize - https://www.codize.ar
55

66
# -*- coding: utf-8 -*-
7+
import logging
8+
79
import odoo
810
from odoo import http
911
from odoo.http import request
1012
import re
11-
13+
_logger = logging.getLogger(__name__)
1214
CORS = '*'
1315

1416
class OdooApiXMLRPC(http.Controller):
@@ -175,6 +177,7 @@ def odoo_api_write(self, model, id=None, vals={}, db=None, login=None, password=
175177
# create #
176178
@http.route('/odoo-api/object/create', type="json", auth='none', cors=CORS)
177179
def odoo_api_create(self, model, vals={}, db=None, login=None, password=None, attributes=None, **kw):
180+
_logger.info(f"odoo_api_create : {vals}")
178181
try:
179182
uid = request.session.authenticate(db, login, password)
180183
if uid:
@@ -193,3 +196,20 @@ def odoo_api_unlink(self, model, id=None, db=None, login=None, password=None, at
193196
return model
194197
except Exception as e:
195198
return {'status': False, 'error': str(e)}
199+
200+
201+
# unlink #
202+
@http.route('/odoo-api/object/action', type="json", auth='none', cors=CORS)
203+
def odoo_api_action(self, model, id=None, action=None, vals={}, db=None, login=None, password=None, attributes=None, **kw):
204+
try:
205+
uid = request.session.authenticate(db, login, password)
206+
if uid:
207+
model = request.env[model].browse(uid).browse(id)
208+
_logger.info(f"MODEL : {model} - ACTION : {action} - VALS : {vals} - ATTRIBUTES : {attributes}")
209+
getattr(model, action)(**vals)
210+
# import ipdb; ipdb.set_trace()
211+
# model.action_post()
212+
# model.action_invoice_paid()
213+
return model
214+
except Exception as e:
215+
return {'status': False, 'error': str(e)}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.