[19.0][ADD] partner_ tier_validation#49
Conversation
Having this rule activated by default in tests environments makes other tests to fail due to the additional constraint not expected by them, so what we are doing is: - Having the rule deactivated by default. - On a post-init hook, we activate it only if we are not in a test environment. - On own modules tests, we activate it as well TT30292
…art validation on controlled field changes
This prevents a scenario where a user can bypass validation by moving the partner to a 'cancel' stage and then moving it back to confirmed.
Currently translated at 100.0% (17 of 17 strings) Translation: partner-contact-18.0/partner-contact-18.0-partner_tier_validation Translate-URL: https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-0-partner_tier_validation/it/
| <field name="arch" type="xml"> | ||
| <!-- Tier Validation UI needs the state field to be in the form --> | ||
| <field name="stage_id" position="before"> | ||
| <field name="state" invisible="1" /> |
There was a problem hiding this comment.
I think that state can be safely removed from here.
I assume that it has been added because it is present in a domain of another field but now, in such case, it is automatically added in the view.
Since this commit: odoo/odoo#137031
9f40fa7 to
278ea63
Compare
|
This PR has the |
| stage = self.env["res.partner.stage"].browse(stage_id) | ||
| vals["state"] = stage.state | ||
| res = super().write(vals) | ||
| if "stage_id" in vals and vals.get("stage_id") in self._state_from: |
There was a problem hiding this comment.
it seems that according previous lines stage_id is an integer the id of res.partner.stage while self._state_form is a list of state when this can be truly ? is it really necessary or do I miss something ?
| revalidate_fields = self._partner_tier_revalidation_fields(vals) | ||
| if any(x in revalidate_fields for x in vals.keys()): | ||
| vals["stage_id"] = self._get_default_stage_id().id |
There was a problem hiding this comment.
non blocking point: To make it easier to read I would suggest to use set with logical operator such as
| revalidate_fields = self._partner_tier_revalidation_fields(vals) | |
| if any(x in revalidate_fields for x in vals.keys()): | |
| vals["stage_id"] = self._get_default_stage_id().id | |
| revalidate_fields = self._partner_tier_revalidation_fields(vals) | |
| if set(vals.keys()) & revalidate_fields: | |
| vals["stage_id"] = self._get_default_stage_id().id |
assuming _partner_tier_revalidation_fields return a set directly
There was a problem hiding this comment.
this file seems useless (I didn't know we support per module test-requirements.txt)
538c9e4 to
d87d4de
Compare
| group_contacts = cls.env.ref("base.group_partner_manager") | ||
| group_approver = cls.env.ref("base.group_no_one") | ||
| User = cls.env["res.users"] | ||
| cls.user_employee = User.create( |
There was a problem hiding this comment.
Could we use new_test_user from odoo.tests.common instead of creating the demo user manually?
|
Please squash the commits as explained here: https://github.com/OCA/maintainer-tools/wiki/Merge-commits-in-pull-requests#mergesquash-the-commits-generated-by-bots-or-weblate |
|
@glitchov This module is not a new addition, so could you please update the PR title and migration commit message as follows? PR title: Migration commit message: |
d87d4de to
567ba5b
Compare
Migration from partner-contact/partner_tier_validation 18.0