-
-
Notifications
You must be signed in to change notification settings - Fork 66
[16.0][IMP] sign_oca enable the user to select all the value of type char, text or m2o from the res.partner object #91
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| from odoo.exceptions import UserError, ValidationError | ||
| from odoo.http import request | ||
| from odoo.tools import float_repr | ||
| from odoo.tools.misc import get_lang | ||
|
|
||
|
|
||
| class SignOcaRequest(models.Model): | ||
|
|
@@ -413,18 +414,35 @@ def _onchange_role_id(self): | |
| def get_info(self, access_token=False): | ||
| self.ensure_one() | ||
| self._set_action_log("view", access_token=access_token) | ||
| partner_fields_dict = {"id": self.partner_id.id} | ||
| for field_name, field_info in ( | ||
| self.env["res.partner"] | ||
| .with_user(self.partner_id.user_id) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line was suspecious to me, I logged and saw that all user_id are just empty recordset: res.partner(7,)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest to add this line above the for loop: In contrast, passing with_user() function did not make change to the returned dictionary, I suggest keeping the former code as it was. |
||
| .fields_get() | ||
| .items() | ||
| ): | ||
| if field_info["type"] in ["char", "text"]: | ||
| partner_fields_dict.update({field_name: self.partner_id[field_name]}) | ||
| if field_info["type"] == "many2one": | ||
| partner_fields_dict.update( | ||
| {field_name: self.partner_id[field_name].name} | ||
| ) | ||
|
Comment on lines
+427
to
+429
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please, don't merge before fixing this line, some models don't have name field and this should be in account as I catch these errors: File "/opt/odoo/auto/addons/sign_oca/controllers/main.py", line 87, in get_sign_oca_info_access
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Manage KeyError if user add a wrong technical field name. |
||
| # add current_date formatted string too | ||
| lang_id = get_lang(self.env, self.env.user.lang) | ||
| partner_fields_dict.update( | ||
| { | ||
| "current_date": fields.Date.context_today(self).strftime( | ||
| lang_id.date_format | ||
| ) | ||
| } | ||
| ) | ||
| return { | ||
| "role_id": self.role_id.id if not self.signed_on else False, | ||
| "name": self.request_id.template_id.name, | ||
| "items": self.request_id.signatory_data, | ||
| "to_sign": self.request_id.to_sign, | ||
| "ask_location": self.request_id.ask_location, | ||
| "partner": { | ||
| "id": self.partner_id.id, | ||
| "name": self.partner_id.name, | ||
| "email": self.partner_id.email, | ||
| "phone": self.partner_id.phone, | ||
| }, | ||
| "partner": partner_fields_dict, | ||
| } | ||
|
|
||
| def sign(self): | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this approach as we are getting all the data of the partner....
My suggestion would be to match with the possible field names. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better approach could be to make only visible the fields availables to group base_user? If there were some.
A mere list seems a hard approach, or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it could be actually a portal user 🤔
The thing is that it is more limited to attach to the fields that we have defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a
with_userto ensure only fields accessible to the user opening the form are added.Do you think this is enough?