[9.0][IMP][base_custom_info] New types and access rules system.#492
Conversation
2f981d9 to
c59de8d
Compare
|
Texts fields should be translatable. Can that be configurable in the definition? I don't think so, but maybe we can make some hack in the method If not, we should define then the field as always translatable but include anyway a flag that allows to specify this translatable possibility. If you don't mark this flag, then at write time, you have to synchronize by code all the translations to the current one, so it behaves as if the field is not translatable in the background. |
|
Why the test coverage drop? |
| To define a template, you need to: | ||
|
|
||
| * Go to *Settings > Custom Info > Templates*. | ||
| * Go to *Custom Info > Templates*. |
There was a problem hiding this comment.
Isn't possible to put inside another top level menu? (we have enough top level menus already)
There was a problem hiding this comment.
I realized that if you have access to setting the templates and values, you should be able to manage them from their menu more comfortably, no need to be an admin for that. Given in v9 the trend is to have more dedicated menus, I'm just following it. Besides, this base module isn't related to any other by default.
I guess the increase of top level menus comes from the enterprise version, where they are beautiful icons in a smartphone-like home panel. After all, the problem is that the backend community interface is way old-fashioned. Nobody will care about them if some day OCA creates a good alternative 😋
There was a problem hiding this comment.
OK, but after this day comes, we have a lot of them... Anyway, if you don't find any parent menu, let's keep it this way. But we should provide then record rules to avoid one person without product access that modifies custom info profiles.
There was a problem hiding this comment.
Forget about the record rule. You have answered me in other comment.
There was a problem hiding this comment.
Note- mobile ready interface is scheduled in one of our sprints, so coming soon 😄
|
About coverage drop, I think it's because this module had no tests and it just got bigger. I'd need some model to implement the Can I declare a new model inside a test? Or do I create a transient model just for testing purposes, that does not appear anywhere else? But it would exist even in production databases... |
|
Make it over res.users model. |
|
Or even over res.partner. They are both models that are in the base module. |
|
Good idea! 💡 |
|
Change spanish translation of the menu "Custom info" to "Inf. personalizada" to shorten the possible the menu width |
| <field name="name">base.custom.info.value.tree</field> | ||
| <field name="model">custom.info.value</field> | ||
| <field name="arch" type="xml"> | ||
| <tree string="Custom Property Values"> |
There was a problem hiding this comment.
Put create="0" delete="0" to avoid modifications on the populated list
There was a problem hiding this comment.
Actually I thought that letting users put additional properties could help under some circumnstances. What do you think?
There was a problem hiding this comment.
I don't think so. This will lead to conflicts (lines that doesn't belong to the same model), and it also break the concept of information template. If you need something extra, make another profile. The only problem I see with this that the same property can't be reused for several templates. Or it can be?
There was a problem hiding this comment.
Not right now. I can add that to known issues.
There was a problem hiding this comment.
BTW, this inability simplifies one algorithm. I'll commit soon.
ad15c7e to
9a88696
Compare
|
This module should be ready, but there's a bug that me and @pedrobaeza found, that seems to affect v9 onchange methods. When you choose a template from the partner form, it fills the values, but properties remain empty: |
|
I honestly don't know why, but it seems to work now, after adding custom tree and form views inside the field. Does anybody know how to disable the button "save & new" in the modal form? |
| from openerp.tools.safe_eval import safe_eval | ||
|
|
||
|
|
||
| class CustomInfoModelLink(models.AbstractModel): |
There was a problem hiding this comment.
Can we get these models in separate files please? Relevant guideline Feel free to ignore me here, my bad didn't realize this wasn't a MIG for a second
|
@lasley Seems impossible. I'd have to add the |
|
This should be ready to merge now. |
|
Lame about the hardcoded form attrs. LGTM thanks @yajo 👍 |
| _name = "custom.info.value" | ||
| _rec_name = 'value' | ||
| _order = "property_id" | ||
| _order = "name" |
There was a problem hiding this comment.
I think this should be ordered by a sequence defined in the template (not sortable at user level).
22d5676 to
736adbc
Compare
|
I rebased to fix conflicts, and took the time to squash some commits. Sorry reviewers 😅. Notice that the really new 2 commits are the last 2. |
11fde67 to
a379e16
Compare
|
That's because travis failures are from other addons, I rebased now, let's see if some get fixed. |
| to_add = props_good - props_enabled | ||
| to_rm = props_enabled - props_good | ||
| # Remove remaining properties | ||
| # HACK https://github.com/odoo/odoo/pull/13480 |
There was a problem hiding this comment.
This is merged, good to remove?
| compute="_compute_dirty_templates", | ||
| ) | ||
|
|
||
| # HACK https://github.com/odoo/odoo/pull/11042 |
There was a problem hiding this comment.
Closed as no-fix. Probably good to remove the comment?
| "dirty_templates").action_custom_info_templates_fill() | ||
| return res | ||
|
|
||
| # HACK https://github.com/odoo/odoo/pull/11042 |
There was a problem hiding this comment.
Closed as no-fix. Probably good to remove the comment?
| info_values.unlink() | ||
| return res | ||
|
|
||
| @api.one |
There was a problem hiding this comment.
Deprecated, please switch to multi
| @api.multi | ||
| def all_custom_info_templates(self): | ||
| """Get all custom info templates involved in these owners.""" | ||
| return (self.mapped("custom_info_template_id") | |
There was a problem hiding this comment.
Bitwise or, on a recordset?
There was a problem hiding this comment.
This works as with normal python sets, joining all results and removing duplicates.
| self.default_value, self.field_type, self) | ||
| except ValueError: | ||
| selection = dict( | ||
| self._fields["field_type"].get_description(self.env) |
There was a problem hiding this comment.
Missing a comma between this and next arg. Although why dict() instead of {}?
| if "value" in vals: | ||
| self.env.context.skip_required = True | ||
| result = super(CustomInfoValue, self).create(vals) | ||
| # HACK https://github.com/odoo/odoo/pull/11042 |
| .action_custom_info_templates_fill() | ||
| return result | ||
|
|
||
| # HACK https://github.com/odoo/odoo/pull/11042 |
| s[s.field_name] = self._transform_value( | ||
| s.value, s.field_type, s.property_id) | ||
|
|
||
| @api.one |
| @api.onchange("property_id") | ||
| def _onchange_property_set_default_value(self): | ||
| """Load default value for this property.""" | ||
| for record in self: |
There was a problem hiding this comment.
No need to rec loop in an onchange
e87ec4a to
0c4e8a1
Compare
| value.ensure_one() | ||
| value = self.env["custom.info.option"].search([ | ||
| ("property_ids", "in", properties.ids), | ||
| ("name", "ilike", u"%{}%".format(value)), |
There was a problem hiding this comment.
These percents do nothing, right? 🤔 (It's not =ilike)
There was a problem hiding this comment.
Uhm, can be, I wasn't sure and put that for assuring.
0c4e8a1 to
6c80dea
Compare
a2939a0 to
0472dfe
Compare
* Now you can define properties types, and access rules are inherited from the model/record linked to the custom info record. * Simplified version of computed value. * Implement for res.partner. * Add tests and fix bugs discovered in the meantime. * Allow to disable partner custom info tab, and custom info menu. * All of it can be set within general settings. * Now, by default, this module does not display custom info for partners unless in demo mode. Better fit for a base module. * You can disable the top menu entry too if it disturbs you, or enable it for everybody. * Give a special form when editing in partner custom info tab. * Sortable properties. * Sort values at onchange time. * Improve performance in onchange. * Split in several model files.
- Select an option with an additional template and get it filled on the owner. - Drop support for onchange, too many bugs to workaround. - Improve demo data. - Improve tests. - Almost cool material icon, this is an app now! - Fun pics.
c70bcf2 to
65967a7
Compare
|
I just tested this and it works like a charm now! I hope I can fix Travis soon & merge, awesome pals. |
|
I tried a Travis rebuild 🤞 |
|
It should go 💚 now. |
Syncing from upstream OCA/server-tools (10.0)

Now you can define properties types, and access rules are inherited from the model/record linked to the custom info record.
@Tecnativa