Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:arrow_up::one::two: res_users_signature #801

Open
wants to merge 1 commit into
base: 12.0
from

Conversation

@fedoranvar
Copy link

commented Aug 7, 2019

No description provided.

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch 3 times, most recently from a2ee717 to c1a0728 Aug 8, 2019

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch 5 times, most recently from 40aca6f to 97b6d39 Aug 9, 2019

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch 6 times, most recently from 4f0913f to 12d6270 Aug 9, 2019

res_users_signature/__manifest__.py Outdated Show resolved Hide resolved
res_users_signature/__manifest__.py Outdated Show resolved Hide resolved

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch 2 times, most recently from 1c47609 to 361df28 Aug 12, 2019

@KolushovAlexandr
Copy link
Member

left a comment

Fix travis errors
Module res_users_signature.models.res_users_signature_models

@@ -1,31 +1,40 @@
Allows create signature templates for users. For example,
===================================
Signature templates for user email

This comment has been minimized.

Copy link
@KolushovAlexandr

KolushovAlexandr Aug 14, 2019

Member

incorrect indents here and almost everywhere below

@@ -1,15 +1,19 @@
{

This comment has been minimized.

Copy link
@KolushovAlexandr

KolushovAlexandr Aug 14, 2019

Member

add licenses

@@ -112,7 +109,7 @@ class IrMailServer(models.Model):
def build_email(self, email_from, email_to, subject, body, email_cc=None, email_bcc=None, reply_to=False,
attachments=None, message_id=None, references=None, object_id=False, subtype='plain', headers=None,
body_alternative=None, subtype_alternative='plain'):
""" copy-pasted from openerp/addons/base/models/ir_mail_server.py::build_email """
""" copy-pasted from odoo/addons/base/models/ir_mail_server.py::build_email """

This comment has been minimized.

Copy link
@KolushovAlexandr

KolushovAlexandr Aug 14, 2019

Member

please ensure that it's not outdated

This comment has been minimized.

Copy link
@fedoranvar

fedoranvar Aug 14, 2019

Author

checked - not outdated.

Does it need to be stated in code somehow?

This comment has been minimized.

Copy link
@KolushovAlexandr
</data>
</openerp>
<odoo>
<record id="administrator" model="res.groups">

This comment has been minimized.

Copy link
@KolushovAlexandr

KolushovAlexandr Aug 14, 2019

Member

do not change indents, just replace openerp with odoo and that's all

This comment has been minimized.

Copy link
@KolushovAlexandr

KolushovAlexandr Aug 14, 2019

Member

otherwise, it's hard to understand did you change smth or not

@@ -58,7 +57,7 @@
</field>
</record>


<!--

This comment has been minimized.

Copy link
@KolushovAlexandr

KolushovAlexandr Aug 14, 2019

Member

Why it was left commented? Add a comment with a reason of its necessity or remove it out

res_users_signature_hr/README.rst Show resolved Hide resolved

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch 3 times, most recently from 6b3b1bc to 9b090c4 Aug 14, 2019

@fedoranvar fedoranvar changed the title :arrow_up::one::two: :arrow_up::one::two: res_users_signature Aug 15, 2019

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch 4 times, most recently from 8502dd4 to 60e4163 Aug 15, 2019

@@ -1,15 +1,25 @@
# Copyright 2019 Ivan Yelizariev <https://it-projects.info/team/yelizariev>

This comment has been minimized.

Copy link
@KolushovAlexandr

KolushovAlexandr Aug 15, 2019

Member

some manifests were renamed from openerp files, so the commit history is lost, please check openerp file for the module before 9158b5b commit

This comment has been minimized.

Copy link
@fedoranvar

fedoranvar Aug 16, 2019

Author

please, explain


<p><img src="data:image/png;base64,ABCDE....12345="/></p>

* RESULT: {what user gets, how the modules changes default behaviour}

This comment has been minimized.

Copy link
@KolushovAlexandr

KolushovAlexandr Aug 15, 2019

Member

forgot to update template string

* Open menu ``[[ {Menu} ]]>> {Submenu} >> {Subsubmenu}``
* Click ``[{Button Name}]``

Allows create signature templates for users. For example,

This comment has been minimized.

Copy link
@KolushovAlexandr

KolushovAlexandr Aug 15, 2019

Member

the sentence does not suit for the article name

@@ -1,38 +1,34 @@
from openerp import fields as old_fields
from openerp import api, models, fields, tools
# Copyright 2019 Ivan Yelizariev <https://it-projects.info/team/yelizariev>

This comment has been minimized.

Copy link
@KolushovAlexandr

KolushovAlexandr Aug 15, 2019

Member

really? look at it
50c8b39

Also, we usually do not relocate files

This comment has been minimized.

Copy link
@KolushovAlexandr

KolushovAlexandr Aug 15, 2019

Member

fix licenses everywhere

This comment has been minimized.

Copy link
@fedoranvar

fedoranvar Aug 16, 2019

Author

i've relocated files because in odoo12 it is a style of placing files

And travis were pointing on this as an error

Usage
=====

* Open menu ``[[ {Menu} ]]>> {Submenu} >> {Subsubmenu}``

This comment has been minimized.

Copy link
@KolushovAlexandr

KolushovAlexandr Aug 15, 2019

Member

attributes from template

This comment has been minimized.

Copy link
@fedoranvar
@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp><data>
</data></openerp>
<odoo>

This comment has been minimized.

Copy link
@KolushovAlexandr

KolushovAlexandr Aug 15, 2019

Member

better delete the file at all

This comment has been minimized.

Copy link
@fedoranvar

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch from 60e4163 to 858c76d Aug 16, 2019

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch from 858c76d to 45431da Aug 19, 2019

@KolushovAlexandr
Copy link
Member

left a comment

Make a note about adding code in Code Mode or how it is called and proper working code for the example signature

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch from 45431da to 4a1db45 Aug 19, 2019

mako = mako_template_env.from_string(tools.ustr(self.signature_id.template))
html = mako.render({'user': self})
tmplt = r"base64,b&#39;(.*?)&#39;" # {&#39;} stands for {'}
repl = "base64," + re.search(r"(?<=base64,b&#39;)(.*?)(?=&#39;)",html).group(1)
html = re.sub(tmplt,repl, html)

This comment has been minimized.

Copy link
@hound

hound bot Aug 19, 2019

missing whitespace after ','

mako = mako_template_env.from_string(tools.ustr(self.signature_id.template))
html = mako.render({'user': self})
tmplt = r"base64,b&#39;(.*?)&#39;" # {&#39;} stands for {'}
repl = "base64," + re.search(r"(?<=base64,b&#39;)(.*?)(?=&#39;)",html).group(1)

This comment has been minimized.

Copy link
@hound

hound bot Aug 19, 2019

missing whitespace after ','

mako = mako_template_env.from_string(tools.ustr(self.signature_id.template))
html = mako.render({'user': self})
tmplt = r"base64,b&#39;(.*?)&#39;" # {&#39;} stands for {'}

This comment has been minimized.

Copy link
@hound

hound bot Aug 19, 2019

at least two spaces before inline comment

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch from 4a1db45 to 011e0c6 Aug 20, 2019

@api.onchange('signature_id')
def render_signature_id(self):
if not self.signature_id:
return
mako = mako_template_env.from_string(tools.ustr(self.signature_id.template))
html = mako.render({'user': self})
pttrn = re.compile(r"base64,b&#39;(.*?)&#39;") # {&#39;} stands for {'}
while pttrn.search(html): # while there is <img>-base64-tags in html

This comment has been minimized.

Copy link
@hound

hound bot Aug 20, 2019

at least two spaces before inline comment

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch 2 times, most recently from f28ab92 to 5a14106 Aug 20, 2019

@KolushovAlexandr
Copy link
Member

left a comment

Cool 👍

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch from 5a14106 to 05cad9f Aug 21, 2019

@em230418
Copy link
Member

left a comment

  1. Не обновляются подписи. Когда редактируем пользователя, меняем шаблон подписи (signature template), видим что подпись поменялась. Нажимаем на сохранить, перезагружаем страницу - у пользователя старая подпись.

  2. Конструкция if не работает или надо поправить документацию c примером (https://github.com/it-projects-llc/misc-addons/blob/05cad9fcd6040bbb8ae5c74cd32a1b1a31e23805/res_users_signature/doc/index.rst)
    FireShot Capture 16 - test1 - Odoo

  3. Случаем не экранирует тэги? Ожидаю, что тегов видно не будет. Если использовать html-элементы невозможно (т.е. подписи могут быть только plaintext), то поправить документацию (убрать тэги).

  4. Допустим поставили двум пользователям один и тот-же signature template. Это admin и demo.
    Далее делаем следующее:
    Settings -> Users & Companies -> Users -> Marc Demo -> Вкладка Preferences -> Signature template -> Кнопка Update signatures.
    Далее выкидывает исключение вот тут:

Стек трейс:

odoo_1           | Traceback (most recent call last):
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/models.py", line 4718, in ensure_one
odoo_1           |     _id, = self._ids
odoo_1           | ValueError: too many values to unpack (expected 1)
odoo_1           | 
odoo_1           | During handling of the above exception, another exception occurred:
odoo_1           | 
odoo_1           | Traceback (most recent call last):
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 661, in _handle_exception
odoo_1           |     return super(JsonRequest, self)._handle_exception(exception)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 319, in _handle_exception
odoo_1           |     raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/tools/pycompat.py", line 87, in reraise
odoo_1           |     raise value
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 703, in dispatch
odoo_1           |     result = self._call_function(**self.params)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 351, in _call_function
odoo_1           |     return checked_call(self.db, *args, **kwargs)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/service/model.py", line 97, in wrapper
odoo_1           |     return f(dbname, *args, **kwargs)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 344, in checked_call
odoo_1           |     result = self.endpoint(*a, **kw)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 946, in __call__
odoo_1           |     return self.method(*args, **kw)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 524, in response_wrap
odoo_1           |     response = f(*args, **kw)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/addons/web/controllers/main.py", line 966, in call_button
odoo_1           |     action = self._call_kw(model, method, args, {})
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/addons/web/controllers/main.py", line 954, in _call_kw
odoo_1           |     return call_kw(request.env[model], method, args, kwargs)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/api.py", line 749, in call_kw
odoo_1           |     return _call_kw_multi(method, model, args, kwargs)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/api.py", line 736, in _call_kw_multi
odoo_1           |     result = method(recs, *args, **kwargs)
odoo_1           |   File "/opt/odoo/vendor/it-projects-llc/misc-addons/res_users_signature/models/res_users_signature_models.py", line 89, in action_update_signature
odoo_1           |     r.action_update_signature_one()
odoo_1           |   File "/opt/odoo/vendor/it-projects-llc/misc-addons/res_users_signature/models/res_users_signature_models.py", line 95, in action_update_signature_one
odoo_1           |     self.user_ids.render_signature_id()
odoo_1           |   File "/opt/odoo/vendor/it-projects-llc/misc-addons/res_users_signature/models/res_users_signature_models.py", line 34, in render_signature_id
odoo_1           |     if not self.signature_id:
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/fields.py", line 979, in __get__
odoo_1           |     record.ensure_one()
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/models.py", line 4721, in ensure_one
odoo_1           |     raise ValueError("Expected singleton: %s" % self)
odoo_1           | ValueError: Expected singleton: res.users(6, 2)
@em230418
Copy link
Member

left a comment

  1. Исправить ошибку от тревиса
res_users_signature/models/res_users_signature_models.py:39:34: E261 at least two spaces before inline comment
@fedoranvar

This comment has been minimized.

Copy link
Author

commented Aug 22, 2019

  1. Не обновляются подписи. Когда редактируем пользователя, меняем шаблон подписи (signature template), видим что подпись поменялась. Нажимаем на сохранить, перезагружаем страницу - у пользователя старая подпись.
  2. Конструкция if не работает или надо поправить документацию c примером (https://github.com/it-projects-llc/misc-addons/blob/05cad9fcd6040bbb8ae5c74cd32a1b1a31e23805/res_users_signature/doc/index.rst)
    FireShot Capture 16 - test1 - Odoo
  3. Случаем не экранирует тэги? Ожидаю, что тегов видно не будет. Если использовать html-элементы невозможно (т.е. подписи могут быть только plaintext), то поправить документацию (убрать тэги).
  4. Допустим поставили двум пользователям один и тот-же signature template. Это admin и demo.
    Далее делаем следующее:
    Settings -> Users & Companies -> Users -> Marc Demo -> Вкладка Preferences -> Signature template -> Кнопка Update signatures.
    Далее выкидывает исключение вот тут:

Стек трейс:

odoo_1           | Traceback (most recent call last):
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/models.py", line 4718, in ensure_one
odoo_1           |     _id, = self._ids
odoo_1           | ValueError: too many values to unpack (expected 1)
odoo_1           | 
odoo_1           | During handling of the above exception, another exception occurred:
odoo_1           | 
odoo_1           | Traceback (most recent call last):
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 661, in _handle_exception
odoo_1           |     return super(JsonRequest, self)._handle_exception(exception)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 319, in _handle_exception
odoo_1           |     raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/tools/pycompat.py", line 87, in reraise
odoo_1           |     raise value
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 703, in dispatch
odoo_1           |     result = self._call_function(**self.params)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 351, in _call_function
odoo_1           |     return checked_call(self.db, *args, **kwargs)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/service/model.py", line 97, in wrapper
odoo_1           |     return f(dbname, *args, **kwargs)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 344, in checked_call
odoo_1           |     result = self.endpoint(*a, **kw)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 946, in __call__
odoo_1           |     return self.method(*args, **kw)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/http.py", line 524, in response_wrap
odoo_1           |     response = f(*args, **kw)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/addons/web/controllers/main.py", line 966, in call_button
odoo_1           |     action = self._call_kw(model, method, args, {})
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/addons/web/controllers/main.py", line 954, in _call_kw
odoo_1           |     return call_kw(request.env[model], method, args, kwargs)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/api.py", line 749, in call_kw
odoo_1           |     return _call_kw_multi(method, model, args, kwargs)
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/api.py", line 736, in _call_kw_multi
odoo_1           |     result = method(recs, *args, **kwargs)
odoo_1           |   File "/opt/odoo/vendor/it-projects-llc/misc-addons/res_users_signature/models/res_users_signature_models.py", line 89, in action_update_signature
odoo_1           |     r.action_update_signature_one()
odoo_1           |   File "/opt/odoo/vendor/it-projects-llc/misc-addons/res_users_signature/models/res_users_signature_models.py", line 95, in action_update_signature_one
odoo_1           |     self.user_ids.render_signature_id()
odoo_1           |   File "/opt/odoo/vendor/it-projects-llc/misc-addons/res_users_signature/models/res_users_signature_models.py", line 34, in render_signature_id
odoo_1           |     if not self.signature_id:
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/fields.py", line 979, in __get__
odoo_1           |     record.ensure_one()
odoo_1           |   File "/opt/odoo/vendor/odoo/cc/odoo/models.py", line 4721, in ensure_one
odoo_1           |     raise ValueError("Expected singleton: %s" % self)
odoo_1           | ValueError: Expected singleton: res.users(6, 2)
    • чтобы применить подпись нужно нажать Update Signatures
  1. В документации указано: войти в режим debug и редактировать в режиме "Code View"
    Если вставлять напрямую в окошко, оно неявно заменяет апострофы, кавычки, <>, на разные кракозябры - поэтому программа-рендер не может обработать условные
    конструкции.
  2. html-тэги работают
  3. исправил- вернул декоратор api.one
  4. исправил

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch from 05cad9f to c27b7af Aug 22, 2019

@fedoranvar fedoranvar force-pushed the fedoranvar:12.0-res_users_signature_hr-port branch from 0f22c62 to a9145c4 Aug 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.