Skip to content

[18.0][FIX] contract: contracts from partners not yet invoiced#1413

Closed
chienandalu wants to merge 1 commit intoOCA:18.0from
moduon:18.0-fix-contract-partner-button
Closed

[18.0][FIX] contract: contracts from partners not yet invoiced#1413
chienandalu wants to merge 1 commit intoOCA:18.0from
moduon:18.0-fix-contract-partner-button

Conversation

@chienandalu
Copy link
Copy Markdown
Member

@chienandalu chienandalu commented Mar 31, 2026

When we have a brand new customer or supplier, we could't see their contracts until those are invoiced and the customer/supplier rank counter is started. Better rely on the existing sale/purchase contracts counter.

image

Should close:

cc @moduon MT-14364

please review @fcvalgar @Gelojr

When we have a brand new customer or supplier, we could't see their
contracts until those are invoiced and the customer/supplier rank
counter is started. Better rely on the existing sale/purchase
contracts counter.

MT-14364
Copy link
Copy Markdown

@fcvalgar fcvalgar left a comment

Choose a reason for hiding this comment

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

Tested and working as expected.

I have verified the behavior by creating the contact from Contacts, Sales, and Purchase. In all cases, the contact correctly shows the corresponding smart button.

Thanks for the fix @chienandalu .
LGTM

Image

@carlosdauden
Copy link
Copy Markdown
Contributor

When contacts are created via the Customer or Supplier actions, the x_rank field is set correctly:
https://github.com/odoo/odoo/blob/be579b408547d45503d3953ee2b3696e76d76992/addons/account/views/partner_view.xml#L352
https://github.com/odoo/odoo/blob/74607bc3196667f282795e0335e84ab95040fd55/addons/account/models/partner.py#L832-L835

When you create a Customer/Supplier following the ‘correct workflow’, you expect the smartbutton to be visible so that you can create a contract from there.

With this change, what will happen to the smartbutton when a Customer/Supplier is created?
I think it’s fine to try to solve a problem that users who don’t follow the ‘correct workflow’ might have, but under no circumstances should this be at the sacrifice of functionality for those who work correctly.

If you want to proceed this way, what you should do is use the _increase_rank method when creating a contract in the same way as when creating an invoice:
https://github.com/odoo/odoo/blob/f5501e5c8dcf60444077912db4c87e7a3f2654a6/addons/account/models/account_move.py#L5239-L5241

ping @sergio-teruel

@chienandalu
Copy link
Copy Markdown
Member Author

Well, yes, taking that perspective I think you're absolutly right. Thanks for you review @carlosdauden 😉

@chienandalu chienandalu closed this Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants