Code Monkey home page Code Monkey logo

sync-addons's People

Contributors

actions-user avatar casvissers-360erp avatar em230418 avatar itpp-bot avatar trojikman avatar yelizariev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sync-addons's Issues

sync: add model to sync_link_refs_uniq_index

This allows to avoid using dynamic relation name like this one:

    model_rel = TG_CHAT_MODEL_REL + params.CHAT_MODEL    
    record_model_link = get_link(model_rel, telegram_user_ref)
    if not record_model_link:
        # ...
        record_model.set_link(model_rel, telegram_user_ref, sync_date=None, allow_many2many=False)

Instead, we can add new parameter model to get_link

Update docs

Customer's feedback:

If you can create documentation, please add more description on fields in Models screen :

  • Call Public methods via API ​--> not clear

  • Restrict Public methods ​--> not clear

  • Allow Private methods ​--> not clear

Also many of the steps in the documentation are not obvious and are confusing, at least in 13.0.
We should add an example of using api applying curl.

openapi[12.0-13.0] error while trying to get date fields

Using demo data I tried to get model's fields with this request:

curl -X PATCH "http://example.com/api/v1/demo/res.partner/call/search_read" -H "accept: application/json" \ -H "authorization: Basic b3BlbmFwaTpiNmQ1NDA1YS0zMWU3LTQ3MjEtYTQyOC0xMmU1OTYzMTYyYzY=" -H "Content-Type: application/json" \ -d "{ \"args\": [[[\"is_company\", \"=\", \"True\" ]]]}"

And got this:

Traceback (most recent call last):
  File "/mnt/addons/sync-addons/openapi/controllers/pinguin.py", line 112, in successful_response
    response = json.dumps(data.ids)
AttributeError: 'list' object has no attribute 'ids'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/addons/sync-addons/openapi/controllers/pinguin.py", line 369, in controller_method_wrapper
    response = controller_method(*iargs, **ikwargs)
  File "/mnt/addons/sync-addons/openapi/controllers/api.py", line 203, in call_method_multi__PATCH
    success_code=pinguin.CODE__success,
  File "/mnt/addons/sync-addons/openapi/controllers/pinguin.py", line 691, in wrap__resource__call_method
    return successful_response(success_code, data=results)
  File "/mnt/addons/sync-addons/openapi/controllers/pinguin.py", line 114, in successful_response
    response = json.dumps(data) if data else None
  File "/usr/local/lib/python3.7/dist-packages/simplejson/__init__.py", line 395, in dumps
    return _default_encoder.encode(obj)
  File "/usr/local/lib/python3.7/dist-packages/simplejson/encoder.py", line 298, in encode
    chunks = list(chunks)
  File "/usr/local/lib/python3.7/dist-packages/simplejson/encoder.py", line 684, in _iterencode
    for chunk in _iterencode_list(o, _current_indent_level):
  File "/usr/local/lib/python3.7/dist-packages/simplejson/encoder.py", line 531, in _iterencode_list
    for chunk in chunks:
  File "/usr/local/lib/python3.7/dist-packages/simplejson/encoder.py", line 652, in _iterencode_dict
    for chunk in chunks:
  File "/usr/local/lib/python3.7/dist-packages/simplejson/encoder.py", line 716, in _iterencode
    o = _default(o)
  File "/usr/local/lib/python3.7/dist-packages/simplejson/encoder.py", line 273, in default
    o.class.name)
TypeError: Object of type datetime is not JSON serializable

This error occurs due to the fact that since odoo 12.0 datetime fields have ceased to be strings

need to fix somewhere here:
12.0: https://github.com/itpp-labs/sync-addons/blob/12.0/openapi/controllers/pinguin.py#L1045-L1064

13.0: https://github.com/itpp-labs/sync-addons/blob/13.0/base_api/lib/pinguin.py#L326-L348

[13.0][OpenAPI] One2many not working

Whenever I use a one2many I seem to be stuck on:

can't adapt type 'dict'

This is the json I use:```

{
"name": "Stock Count",
"line_ids": [
{
"product_id": 1513,
"location_id": 541,
"inventory_id": 1
}
],
"state": "confirm",
"start_empty": "True"
}

I want to create a stock inventory with new lines in the same post.

sync_telegram: can't unsubscribe the channel

Steps to reproduce the issue:

  1. Send a message to the bot via Telegram
  2. Recieve message via Discuss in Odoo
  3. Click on the cross to unsubscribe from the channel
  4. Refresh the page
    Result: We still see the channel and still subscribed to it

Expected behavior: be able to unsubscribe from the channel

Screencast.2021-06-28.15.25.07.mp4

Openapi: OpenAPI specification mismatch

Some examples:
Request from Joel Willis (who does not have permission to read fields):
curl -X GET "http://localhost/api/v1/demo/res.partner/1" -H "accept: application/json" \ -H "authorization: Basic b3BlbmFwaTpmMTY3OTlhMC1hNWNlLTRjNTYtOTQ5ZC02YWE3NmY2OTAzYmQ="

The answer is 500 Internal Server Error

It was also noted that the responses do not meet the specifications of Openapi

sync_telegram: error when the bot is blocked

Steps to reproduce the error:

  1. Start messaging with the bot via telegram and block it after that
  2. Try to send a message via Odoo with the user without Administration/Settings access rights
    Result: You'll see something like that:
    Screenshot from 2021-08-23 17-20-26

If we try to send the message via the user with Administration/Settings access rights we'll get this error:

Odoo Server Error
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
    result = request.dispatch()
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 683, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 359, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 347, in checked_call
    result = self.endpoint(*a, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 912, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 531, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1377, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1369, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 396, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 383, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_channel.py", line 416, in message_post
    message = super(Channel, self.with_context(mail_create_nosubscribe=True)).message_post(message_type=message_type, moderation_status=moderation_status, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_thread.py", line 1888, in message_post
    self._notify_thread(new_message, values, **notif_kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_channel.py", line 542, in _notify_thread
    super(Channel, self)._notify_thread(message, msg_vals=msg_vals, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/sms/models/mail_thread.py", line 236, in _notify_thread
    recipients_data = super(MailThread, self)._notify_thread(message, msg_vals=msg_vals, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_thread.py", line 2135, in _notify_thread
    self._notify_record_by_inbox(message, rdata, msg_vals=msg_vals, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_thread.py", line 2153, in _notify_record_by_inbox
    message.write({'channel_ids': [(6, 0, channel_ids)]})
  File "/usr/lib/python3/dist-packages/odoo/addons/base_automation/models/base_automation.py", line 348, in write
    action._process(records, domain_post=domain_post)
  File "/usr/lib/python3/dist-packages/odoo/addons/base_automation/models/base_automation.py", line 273, in _process
    raise e
  File "/usr/lib/python3/dist-packages/odoo/addons/base_automation/models/base_automation.py", line 270, in _process
    self.action_server_id.sudo().with_context(**ctx).run()
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions.py", line 629, in run
    res = runner(run_self, eval_context=eval_context)
  File "/usr/lib/python3/dist-packages/odoo/addons/website/models/ir_actions.py", line 61, in _run_action_code_multi
    res = super(ServerAction, self)._run_action_code_multi(eval_context)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions.py", line 498, in _run_action_code_multi
    safe_eval(self.code.strip(), eval_context, mode="exec", nocopy=True)  # nocopy allows to return 'action'
  File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 346, in safe_eval
    raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr))
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 639, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 315, in _handle_exception
    raise exception.with_traceback(None) from new_cause
ValueError: <class 'ValueError'>: "<class 'telegram.error.Unauthorized'>: "Forbidden: bot was blocked by the user" while evaluating
'\ndef handle_db(records):\n    # records are instances of mail.message\n    for mail_message in records:\n        for channel in mail_message.channel_ids:\n            if channel.channel_type != \'telegram\':\n                continue\n            channel_link = channel.search_links(TG_CHAT_CHANNEL_REL)\n            if not channel_link:\n                continue\n\n            telegram_user_ref = channel_link.external\n            #channel_link = get_link(TG_CHAT_CHANNEL_REL, telegram_user_ref)\n\n            if not mail_message.author_id.search_links(TG_PARTNER_REL) and mail_message.author_id.id != odoobot_id:\n                log("MESSAGE from odoo: channel_id %s - author_id %s - attachment_ids: %s - message_text: %s" % (mail_message.res_id, mail_message.author_id.id, mail_message.attachment_ids, mail_message.body), LOG_DEBUG)\n\n                if mail_message.body:\n                    message_html = "%s\\n\\n<i>%s</i>" % (mail_message.body, mail_message.author_id.name)\n                    telegram.sendMessage(telegram_user_ref, message_html, parse_mode=\'HTML\')\n\n                if mail_message.attachment_ids:\n                    for attach in mail_message.attachment_ids:\n                        log("ATTACHMENT from odoo: attach.id %s - name %s" % (attach.name, attach.id), LOG_INFO)\n\n                        if attach.mimetype and "/" in attach.mimetype and attach.mimetype.split("/")[0] == "image":\n                            if  attach.file_size < telegram.MAX_SIZE_IMAGE:\n                                telegram.sendPhoto(telegram_user_ref, attach.datas)\n                            else:\n                                channel.message_post(body="You cannot send more than 10 MB for photos.",\n                                    author_id=odoobot_id, message_type="comment", subtype_xmlid="mail.mt_comment")\n                        else:\n                            if  attach.file_size < telegram.MAX_SIZE_DOCUMENT:\n                                telegram.sendDocument(telegram_user_ref, attach.name, attach.datas)\n                            else:\n                                channel.message_post(body="You cannot send more than 50 MB for documents.",\n                                    author_id=odoobot_id, message_type="comment", subtype_xmlid="mail.mt_comment")\n\n\n\n        \nEXECUTION_RESULT_ = handle_db(*EXECUTION_ARGS_, **EXECUTION_KWARGS_)\n        '" while evaluating
'env["sync.trigger.automation"].browse(4).sudo().start(records)'

Expected behavior: in cases when the user blocks the Bot in Odoo we need to understand what's happened without any errors

Sync: ValueError: Compute method failed to assign sync.trigger.webhook

Steps to reproduce:

  1. Go to Sync Projects
  2. Create a new one
  3. Go to Available Tasks tab and Add a line
  4. Go to Avalable Triggers tab
  5. In Webhooks section add a new line and get the following error:
Error:
Odoo Server Error

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
    result = request.dispatch()
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 683, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 359, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 347, in checked_call
    result = self.endpoint(*a, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 912, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 531, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1377, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1369, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 396, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 383, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 6242, in onchange
    snapshot1 = Snapshot(record, nametree)
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 6047, in __init__
    self.fetch(name)
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 6057, in fetch
    self[name] = record[name]
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 5664, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1024, in __get__
    raise ValueError("Compute method failed to assign %s.%s" % (record, self.name))
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 639, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 315, in _handle_exception
    raise exception.with_traceback(None) from new_cause
ValueError: Compute method failed to assign sync.trigger.webhook(<NewId 0x7f1ab22040f0>,).website_url

Affected versions: the error experienced in 14.0 but we need previous versions after fixing it in 14.0

OpenAPI: 500 Internal Server Error server error response code in case of Log request = Short

OpenAPI 13.0.1.2.1
Log Requests = Short

curl -X PATCH "http://demo.server.info/api/v1/demo/res.partner/call/search_read_nested" -H "accept: application/json" -H "authorization: Basic YWRtaW46YTg2NTQwYzYtYWMyZC00NzVhLTgyNzYtNzFhY2MxMTUzYjQ5" -H "Content-Type: application/json" -d "{ "args": [[["id", ">", "0"]], [ "name","id" ] ]}"

<title>500 Internal Server Error</title>

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

2020-09-16 07:29:41,182 13 ERROR demo odoo.addons.openapi.controllers.apijsonrequest: Exception during JSON request handling.
Traceback (most recent call last):
File "/mnt/extra-addons/openapi/controllers/apijsonrequest.py", line 108, in _handle_exception
return super(ApiJsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 310, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 14, in reraise
raise value
File "/mnt/extra-addons/openapi/controllers/apijsonrequest.py", line 159, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 350, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 915, in call
return self.method(*args, **kw)
File "/mnt/extra-addons/openapi/controllers/apijsonrequest.py", line 200, in response_wrap
response = f(*args, **kw)
File "/mnt/extra-addons/openapi/controllers/pinguin.py", line 386, in controller_method_wrapper
create_log_record(**data_for_log)
File "/mnt/extra-addons/openapi/controllers/pinguin.py", line 284, in create_log_record
_create_log_record(env, **kwargs)
File "/mnt/extra-addons/openapi/controllers/pinguin.py", line 323, in _create_log_record
del log_data["request_data"][k]
KeyError: 'form'
2020-09-16 07:29:41,184 13 ERROR demo odoo.addons.openapi.controllers.apijsonrequest: Exception during JSON request handling.
Traceback (most recent call last):
File "/mnt/extra-addons/openapi/controllers/apijsonrequest.py", line 108, in _handle_exception
return super(ApiJsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 310, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 14, in reraise
raise value
File "/mnt/extra-addons/openapi/controllers/apijsonrequest.py", line 159, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 350, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 915, in call
return self.method(*args, **kw)
File "/mnt/extra-addons/openapi/controllers/apijsonrequest.py", line 200, in response_wrap
response = f(*args, **kw)
File "/mnt/extra-addons/openapi/controllers/pinguin.py", line 386, in controller_method_wrapper
create_log_record(**data_for_log)
File "/mnt/extra-addons/openapi/controllers/pinguin.py", line 284, in create_log_record
_create_log_record(env, **kwargs)
File "/mnt/extra-addons/openapi/controllers/pinguin.py", line 323, in _create_log_record
del log_data["request_data"][k]
KeyError: 'form'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/mnt/extra-addons/openapi/controllers/apijsonrequest.py", line 108, in _handle_exception
return super(ApiJsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 310, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 14, in reraise
raise value
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 229, in _dispatch
result = request.dispatch()
File "/mnt/extra-addons/openapi/controllers/apijsonrequest.py", line 181, in dispatch
return self._handle_exception(e)
File "/mnt/extra-addons/openapi/controllers/apijsonrequest.py", line 121, in _handle_exception
"code": exception.response.status_code,
AttributeError: 'KeyError' object has no attribute 'response'
2020-09-16 07:29:41,191 13 INFO demo werkzeug: 172.17.0.1 - - [16/Sep/2020 07:29:41] "PATCH /api/v1/demo/res.partner/call/search_read_nested HTTP/1.0" 500 - 28 0.043 0.067
2020-09-16 07:29:41,198 13 ERROR demo werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 270, in run_wsgi
execute(self.server.app)
File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 258, in execute
application_iter = app(environ, start_response)
File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py", line 142, in application
return application_unproxied(environ, start_response)
File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py", line 117, in application_unproxied
result = odoo.http.root(environ, start_response)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1287, in call
return self.dispatch(environ, start_response)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1257, in call
return self.app(environ, start_wrapped)
File "/usr/lib/python3/dist-packages/werkzeug/wsgi.py", line 766, in call
return self.app(environ, start_response)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1457, in dispatch
result = ir_http._dispatch()
File "/usr/lib/python3/dist-packages/odoo/addons/auth_signup/models/ir_http.py", line 19, in _dispatch
return super(Http, cls)._dispatch()
File "/usr/lib/python3/dist-packages/odoo/addons/web_editor/models/ir_http.py", line 21, in _dispatch
return super(IrHttp, cls)._dispatch()
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 233, in _dispatch
return cls._handle_exception(e)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 201, in _handle_exception
return request._handle_exception(exception)
File "/mnt/extra-addons/openapi/controllers/apijsonrequest.py", line 121, in _handle_exception
"code": exception.response.status_code,
AttributeError: 'AttributeError' object has no attribute 'response' - - -
2

sync: new parameter type - sync.project.odoo

class SyncProjectReference(models.Model):

    _name = "sync.project.odoo"
    _description = "Project References"
    _inherit = "sync.project.param.mixin"

    def _selection_ref_model(self):
        self.ensure_one()
        return [(self.model_id.model, self.model_id.name)]

   def _get_value_domain(self):
        self.ensure_one()
        domain = # TODO convert self.domain from string to real domain
        return domain


    model_id = fields.Many2one()
    model_name = fields.Char(realted='model_id.model')
    domain = fields.Char()
    value = fields.Reference(string='Record', selection=_selection_ref_model, domain=lambda s: s._get_value_domain)
                                <field name="value" />
                                <field name="model_id" groups="base.group_no_one" />
                                <field name="model_name" invisible="1" />
                                <field name="domain" widget="domain" options="{'model': 'model_name', 'in_dialog': True}" groups="base.group_no_one"/>

usage example: specify User or Group via reference widget rather than just putting ID

sync: delete link if odoo record doesn't exist anymore

links = self.search(domain)

Could be replaced with:

    links = self.search(domain)
    odoo_links = links.filtered(lambda r: r.system1 == ODOO)
    odoo_links_to_delete = odoo_links - odoo_links.exists()
    if odoo_links_to_delete:
        self._log("Delete obsolete links: {}".format([(link.odoo, link.relation, link.system2, link.ref2, link.date) for link in odoo_links_to_delete))
    odoo_links = odoo_links - odoo_links_to_delete

Update docs about http://editor.swagger.io/

The web editor sends requests directly from browser which leads to CORS error. The user must be aware of it. We need suggest him to copy-paste curl command and ignore the inline error.

Additional thing to do is provide an instuction how to allows CORS requests. It should be settings on nginx side (plus a note that it's not available on odoo.sh), e.g.

location /api/v1 {
     if ($request_method = 'OPTIONS') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain charset=UTF-8';
        add_header 'Content-Length' 0;
        return 204;
     }
     if ($request_method = 'POST') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Credentials' 'true';
     }
     if ($request_method = 'GET') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Credentials' 'true';
     }
}

from https://serverfault.com/questions/162429/how-do-i-add-access-control-allow-origin-in-nginx

sync_shopify

Proof of concept implementation.

The module should just sync list of products (names and photos), similar to sync_woo

Odoo version: 14.0

API: https://shopify.dev/api/admin
Python lib: https://github.com/Shopify/shopify_python_api#private-apps

Shopify is not opensource. You need to signup get a free trial:

  1. Log in to your store as the store owner.
  2. From your Shopify admin, go to Apps.
  3. Click Manage private apps.
  4. Click Enable private apps.
  5. Read and check the terms, and then click Enable private app development.
  6. Click "Create private app"
  7. Activate access to products ("read and write")

https://github.com/itpp-labs/sync-addons/tree/14.0/sync#public-webhook-address

The module docs will be checked first! No docs = no way to check the module. The doc must have instruction how to get access token.

OpenAPI: non-compliance with specification and other stranger things [draft]

1. Different behavior between curl and Bravado
I have noticed the difference between sending PUT requests to API between curl and python library Bravado, there will be different behavior because of specification flaw. And because bravado works according to specification it imposes a restriction on freedom of action and completeness of the user experience.

Example:
If we try to create new record via curl we can fill in the x2many field by passing new record (like [0, 0, values]) but in case of using Bravado we can only pass record id.
What to do:
In this case, I'm not entirely sure which option is more correct but I think that everything should work the same in both cases.

2. Response codes don't meet specification (from #152)
Here are some examples:

  1. Request from allowed user without rights to read fields in odoo (Joel Willis if you use demo data) will get you an internal error.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

sync: updates backport

From #216 we have to backport following updates:

13.0 only:

Following updates are already in v12

  • add helpers for one2one synchronization
  • sync: show icon in app switcher in Odoo EE
  • sync: allow empty values for project.eval_context

12.0 and 13.0

  • sync: add tokens for incoming webhooks
  • sync: export xml: add missed webhook_type field
  • sync: allow run without telegram package installed

openapi: User with admin rights, but without OpenAPI access cannot open Settings menut

Versions: 10,11,12

Error:

Odoo Warning - Access Error
Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:
- OpenAPI/User
- OpenAPI/Manager

(Document model: openapi.namespace) - (Operation: read, User: 5)

screenshot-22732-10-0-7c8e42-all runbot it-projects info-2020 04 02-15_38_43

Solution: hide block when a user doesn't have access

REF: APPS-40

openapi: can't get single record [tested in odoo 13.0]:

Steps to reproduce:

Try to find a record existing in one instance applying search method like this:

curl -X PATCH "http://example.com/api/v1/demo/res.partner/call/search" -H "accept: application/json" -H "authorization: Basic b3BlbmFwaTpiNmQ1NDA1YS0zMWU3LTQ3MjEtYTQyOC0xMmU1OTYzMTYyYzY=" -H "Content-Type: application/json" -d "{ \"args\": [[[\"name\", \"=\", \"YourCompany\"]]]}"

you will not get any response

At this time in the odoo logs there are no errors or anything else strange

telegram lib

Version must be

git+https://github.com/python-telegram-bot/[email protected]

because latest doesn't work with python 3.5

odoo_1  |   File "/opt/odoo/custom/src/odoo/odoo/modules/module.py", line 82, in load_module
odoo_1  |     exec(open(modfile, 'rb').read(), new_mod.__dict__)
odoo_1  |   File "<string>", line 3, in <module>
odoo_1  |   File "/opt/odoo/auto/addons/sync/models/__init__.py", line 4, in <module>
odoo_1  |     from . import sync_project_demo
odoo_1  |   File "/opt/odoo/auto/addons/sync/models/sync_project_demo.py", line 10, in <module>
odoo_1  |     from telegram import Bot, Update
odoo_1  |   File "/usr/local/lib/python3.5/site-packages/telegram/__init__.py", line 21, in <module>
odoo_1  |     from .base import TelegramObject
odoo_1  |   File "/usr/local/lib/python3.5/site-packages/telegram/base.py", line 42
odoo_1  |     _id_attrs: Tuple[Any, ...] = ()

The version must be set in DINAR https://github.com/itpp-labs/sync-addons/blob/13.0/.DINAR/image/dependencies/pip.txt
(v12 at least)

Plus we have to make a note in installation instruction of Sync Studio.

Ideally, we need to switch to this lib instead https://github.com/eternnoir/pyTelegramBotAPI

sync: protecting parameters from updating

Parameters/Secrets must not be updated on module upgrading.

  1. Create new method create_empty_param(name, description, url, project_id)

  2. On project exporting use the method:

      <function model="sync.project.secret" name="create_empty_param" eval="('TRELLO_KEY', '', 'https://trello.com/app-key', ref('sync.trello-github_project'))" />
    

Currently following node is generated:

    <record id="trello-key_project-secret-parameter" model="sync.project.secret">
        <field name="key">TRELLO_KEY</field>
        <field name="description" />
        <field name="url" eval="'https://trello.com/app-key'" />
        <field name="project_id" ref="sync.trello-github_project" />
    </record>

sync_telegram: get lib importing out of try-block

it was copy-pasted from sync module, where telegram is demo and we don't require to installing telegram package

try:
# https://github.com/python-telegram-bot/python-telegram-bot
from telegram import ( # pylint: disable=missing-manifest-dependency
Bot,
Update,
)
except (ImportError, IOError) as err:
_logger.debug(err)

Superadmin user loses access to Apps and Settings menu

Create an OpenAPI by demo
Make sure that only the demo user is allowed to use the OpenAPI.
Edit an OpenAPI by Admin
Result: admin and superuser loses access to the Apps and Settings menu

Sorry, you are not allowed to modify documents of type 'Integration' (openapi.namespace). This operation is allowed for the groups:

  • OpenAPI/Manager - (Operation: write, User: 6)

Sorry, you are not allowed to access documents of type 'Module' (ir.module.module). This operation is allowed for the groups:

  • Administration/Settings - (Operation: read, User: 6)

sync: finish porting to v13

<!-- Delete in Odoo 13 -->
<button
name="toggle_active"
type="object"
class="oe_stat_button"
icon="fa-archive"
>
<field
name="active"
widget="boolean_button"
options='{"terminology": "archive"}'
/>
</button>

<!-- Uncomment in Odoo 13
<widget name="web_ribbon" text="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>
<field name="active" invisible="1" />
-->

[v12] openapi - keep getting 405 error

Hi,

i am using V12 , openapi module but
after installed and tried, it kept throwing ,
"OPTIONS /api/v1/my_test_namespace/res.users/1 HTTP/1.1" 405 - 2 0.008 0.016

not sure what went wrong, i have tried to put the openapi
at my config file in the server_wide_modules = ... , which is the same as load=
at command line right?

and module installed and configured but it seems that not working when
i tried at editor.swagger.io with the token copied from my
user's OpenAPI Token or at the integrations, Identification token.

appreciate any advice.
thanks.

sync_odoo2odoo_pos

Depends on #304

Idea is allowing to start POS from local server, push orders to local server, then push order from local server to main server. It could be useful when it's problematic to use main server directly because of connection issues.

Main2local

  • products
  • POS configs
  • payment methods

Local2main

  • pos sessions
  • pos orders

sync_odoo2odoo

Make a separate module similar to a demo project in sync module

Eval context should have new methods similar to sync helpers https://github.com/itpp-labs/sync-addons/blob/e924974e60ba40fbc7b700a96b1d95b9932e3640/sync/doc/index.rst#sync-helpers

sync_odoo2odoo_push(model_name, domain=None, fields=None, active_test=True, create=False, update=False)
sync_odoo2odoo_pull(model_name, domain=None, fields=None, active_test=True, create=False, update=False)

  • create: boolean value for "create record if it doesn't exist"
  • update: boolean value for "update record if it exists"
  • domain: which records of model_name to sync
  • fields: which fields to sync
  • active_test: value to pass to context on reading

open api [13.0] - openapi_token not unique

When installing the module on a database with multiple users, all users get the same openapi_token which results in a singleton error when making an API call.

I think the openapi_token should get a unqiue contraint and in addition the token should be regenerated per user when getting the default token, or a token should only be created on request?

@aschenkels-ictstudio

[14.0] Failed to fetch the response

I'm getting the following error in V14.

Undocumented Error

No Errors in the Logger
2021-06-01 11:08:45,375 11544 INFO ? werkzeug: 127.0.0.1 - - [01/Jun/2021 11:08:45] "OPTIONS /api/v1/mobile/res.partner HTTP/1.1" 405 - 1 0.003 0.006

Note: Configured the --load openapi,base,web and Authorization have done based on the Documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.