Skip to content

[19.0][ADD] partner_ tier_validation#49

Open
glitchov wants to merge 27 commits into
OCA:19.0from
acsone:19.0-add-partner_tier_validation-hda
Open

[19.0][ADD] partner_ tier_validation#49
glitchov wants to merge 27 commits into
OCA:19.0from
acsone:19.0-add-partner_tier_validation-hda

Conversation

@glitchov

@glitchov glitchov commented May 20, 2026

Copy link
Copy Markdown

Migration from partner-contact/partner_tier_validation 18.0

dreispt and others added 25 commits May 20, 2026 09:04
- Added new optional tier definition for is_company = true.
- Added auto active if no validation needed during create.
- Added reset validation during write for specific fields.

[FIX] Code White Space Formatting

[IMP] Reviewer Suggestions

[IMP] Added Tests
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
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/
@OCA-git-bot OCA-git-bot added mod:partner_tier_validation Module partner_tier_validation series:19.0 labels May 20, 2026
@glitchov glitchov changed the title [19.0][ADD] partne_ tier_validation [19.0][ADD] partner_ tier_validation May 20, 2026

@FrancoMaxime FrancoMaxime left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM: code review

@AnizR AnizR left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution 🚀

<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" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@glitchov glitchov force-pushed the 19.0-add-partner_tier_validation-hda branch from 9f40fa7 to 278ea63 Compare June 10, 2026 11:04

@AnizR AnizR left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, thanks! 🚀

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Comment on lines +38 to +40
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non blocking point: To make it easier to read I would suggest to use set with logical operator such as

Suggested change
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file seems useless (I didn't know we support per module test-requirements.txt)

@glitchov glitchov force-pushed the 19.0-add-partner_tier_validation-hda branch 3 times, most recently from 538c9e4 to d87d4de Compare June 12, 2026 06:31
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(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use new_test_user from odoo.tests.common instead of creating the demo user manually?

@BhaveshHeliconia

Copy link
Copy Markdown

@BhaveshHeliconia

Copy link
Copy Markdown

@glitchov This module is not a new addition, so could you please update the PR title and migration commit message as follows?

PR title:

[19.0][MIG] partner_tier_validation: Migration to 19.0

Migration commit message:

[MIG] partner_tier_validation: Migration to 19.0

@glitchov glitchov force-pushed the 19.0-add-partner_tier_validation-hda branch from d87d4de to 567ba5b Compare June 18, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.