Skip to content

[20.0] [MIG] contract: Migration to 20.0 - #1566

Open
Borruso wants to merge 304 commits into
OCA:20.0from
Borruso:20.0-mig-contract
Open

Borruso wants to merge 304 commits into
OCA:20.0from
Borruso:20.0-mig-contract

Conversation

@Borruso

@Borruso Borruso commented Oct 20, 2026

Copy link
Copy Markdown

sbejaoui and others added 30 commits October 20, 2026 11:31
[FIX] - as date_start is required, constraints on it become useless
[FIX] - for finished contract _get_lines_to_invoice should return False
[FIX] - default value for active field in contract line
[FIX] - fix flake8
[IMP] - check invoice line vals before assignment
[FIX] - Fix unit tests.
[FIX] - do not copy last_date_invoiced on plan_successor
[FIX] - renew only recurring_invoices contract
[FIX] - filter by termination_notice for contract line to renew
[IMP] - Improve inprogress search filter
[IMP] - Link invoice line to contract lines
[IMP] - Add index on contract line
[IMP] - Add is_suspended flag and _search_state
[IMP] - Add is_suspended flag to stop contract line
[MV] - move onchange method to contract_product module
[IMP] - Replace is_suspended flag by manual_renew_needed
  Add a computed field for the first date of the termination notice period
  Adapt state compute and search method
[IMP] - Improve unit tests
[ADD] Contract: new contributor

[REF] Contract: indexes
…ll + rename recurring_interval to Invoice Every
[REF] - refactoring for compute_first_date_end

[RMV] - remove auto_renew_rule_type option monthlylastday

[IMP] - rename manual_renew_needed label

[IMP] - use get_product_multiline_description_sale to get contract line description
[FIX] - manual_renew_needed should be visible to all contract users
[REF] - add _get_next_invoiced_period method
[FIX] - Fix In progress contract filter
[REF] - add method to get quantity to invoice
  the contract line quantity can be in some use cases variable, to simplify
  the way it is changed we add a new method _get_quantity_to_invoice.
[FIX] - Onchange contract line don't reste contract lines
[FIX] - Rename _get_invoiced_period to _get_period_to_invoice
[ADD] - Add stop_at_date_end to _get_period_to_invoice
[FIX] - Remove useless filter
[FIX] - don't play onchange date_start for old lines on contract template change
[FIX] - Fix stop post message
[FIX] - Fix sale_contract_count should count all partner contract
[FIX] - set recurring_next_date to False if contract line stoped at last date invoiced
[FIX] - Group by next_invoice also considers dates in the past
[IMP] - A canceled contract line can't be set to auto-renew
[REF] Contract: pep8
[IMP] Contract: update USAGE section of README
[IMP]call onchange_is_auto_renew when changing template
[REF] use context_today instead of time in filters
[REF] Contract: split from analytic account
[REF] Contract Sale Invoicing: split from analytic account
[REF] Contract Sale Invoicing: update translations
[IMP] - Assert that the predecessor is available for new link at uncancel
[RMV] - remove usless changes
[RMV] - Remove usless field recurring_invoices
  after the total isolation between contract model and account analytic one.
  recurring_invoices which was used to mark analytic account as contract became usless
[IMP] - P3 syntax
[IMP] - use @openupgrade.migrate() and openupgrade.logged_query
[IMP] - drop transient table in migration script
[RMV] - Remove empty file

[IMP] - Update no_update cron after migration

[IMP] - move contract template recurrence info to line level

[FIX] - Fix contract line model description

[IMP] - Link contracts to analytic accounts

[FIX] - Fix pylint

[IMP] - Move chatter and attachments from analytic account to contract

[IMP] - Move account_analytic_id to contract line level

[IMP] - Improve version check in migration script

[IMP] - Move contracts followers from analytic accounts

[ADD] - Add mail.activity.mixin to contract.contract model

remove data drop from migration scripts

[12.0][FIX] - Fix _init_last_date_invoiced

fix flake8

[ADD] - Update contributors list
* Remove incorrect oldname attributes.
* Add filter on partners for running contracts (+ a support o2m field for that).
* Cover more tables in model renaming + cleaner code using a loop.
* Don't copy contract lines, but rename table + copy contract records on pre.
* Contract code is now populated to "Reference/Description" field in invoice.
* Order on new contract model has been restored to the same as old analytic accounts.
Currently translated at 100.0% (211 of 211 strings)

Translation: contract-12.0/contract-12.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract/zh_CN/
Currently translated at 96.2% (204 of 212 strings)

Translation: contract-12.0/contract-12.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract/it/
As v11 takes salesman from linked partner and now the salesman is a field in the
contract that is initialized to current user, we need to assign to the recently
converted contracts following old logic, or they will have admin as responsible.
Currently translated at 78.8% (167 of 212 strings)

Translation: contract-12.0/contract-12.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract/de/
The lowest model access for contract.contract model is group_account_invoice group. However the addon adds two smart buttons to res.partner view without any security restrictions and without compute_sudo attribute on computed fields.
This causes the view to crash when a user without the proper permissions tries to access the res.partner form view.
The solution adds groups_id to the partner form views in which the buttons are added, so the only loads when the user has proper permissions.
Other way to solve it would be to add compute_sudo attribute to the relevant fields, but this causes an access error when the user clicks on the smart buttons.
Currently translated at 61.3% (130 of 212 strings)

Translation: contract-12.0/contract-12.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract/ca/
Currently translated at 100.0% (212 of 212 strings)

Translation: contract-12.0/contract-12.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract/pt_BR/
Currently translated at 98.1% (208 of 212 strings)

Translation: contract-12.0/contract-12.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract/nl/
Currently translated at 100.0% (212 of 212 strings)

Translation: contract-12.0/contract-12.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract/es/
…tract partner label + contract company must be the same as the sale order

- multi-company record rules on contract line causes performance issue
- the label Partner (always False) don't make any sens
- When creating a contract from a sale order the company must be the sale order
  company and not the user company
Don't transfer to contract those analytic accounts with the "Recurring invoicing" flag
unchecked.
Currently translated at 21.7% (46 of 212 strings)

Translation: contract-12.0/contract-12.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract/hr/

@max3903 max3903 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.

Left to fix

  • Portal home count never runs. _prepare_home_portal_values is not called in 20.0 (/my/counters uses _prepare_portal_counter_values). Override that for contract_count, as account and sale do, or the Contracts card on /my stays at 0.
  • Add maintainers to __manifest__.py.

@max3903

max3903 commented Nov 8, 2026

Copy link
Copy Markdown
Member

/ocabot migration contract

@OCA-git-bot OCA-git-bot mentioned this pull request Nov 8, 2026
12 tasks
@Borruso
Borruso requested a review from max3903 November 9, 2026 08:33
@oca-cla-bot

oca-cla-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@bm1-phillip bm1-phillip 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.

Functional review on Odoo 20.0 Community (nightly 20261110), l10n_de (SKR03), head 3636f37. We run this module in production on 19.0 for our recurring invoices.

The 78 tests pass (the portal tour is skipped here, there is no browser in my image), no warnings from the module in the server log.

What we use works, checked in a shell with contracts created through the ORM:

  • Monthly post-paid with the next invoice on the 1st: the period is the previous month, the invoice is dated the 1st, #START# and #END# are replaced in the partner's date format, and the next date moves one month on.
  • Half-yearly and yearly pre-paid contracts.
  • cron_recurring_create_invoice() invoices what is due and nothing else.

One problem in the form view: section and note lines are shown as empty rows.

  1. Open a customer contract with a product line.
  2. "Add a section", enter a title, "Save & Close".
  3. The new row is there, but empty. Note lines look the same.

The browser console says Missing widget: product_label_section_and_note_field for field of type many2one and Missing widget: section_and_note_text for field of type text. views/contract.xml (both line lists) and views/contract_template.xml still use these field widgets. They are gone in 20.0: the invoice lines in account/views/account_move_views.xml now use account_product_field and text inside the product_label_section_and_note_field_o2m list.

@notsebtho notsebtho 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.

Tested on Odoo 20.0 at 3636f37, together with #1568, #1574 and #1575. The four modules install cleanly and the combined test run passes (132 tests, 0 failed, 0 errors). Three of our demo databases that use contracts (a logistics company, a coworking space and a gym) also install with no errors.

On the open points:

  • The portal counter from max3903's review looks fixed: _prepare_portal_counter_values now handles contract_count, and the Contracts card is a portal.entry record.
  • maintainers is in the manifest now, but as an empty list.
  • I can confirm the widget problem bm1-phillip reported. product_label_section_and_note_field and section_and_note_text aren't registered anywhere in Odoo 20.0. They're used on the product_id and name fields of both line lists in views/contract.xml (lines 168, 173, 255 and 260) and on name in views/contract_template.xml (line 65). The invoice lines in account_move_views.xml now use widget="account_product_field" on product_id and widget="text" on name, inside the product_label_section_and_note_field_o2m list, which contract already uses. Switching to those should fix the empty section and note rows.

I'll approve once the widgets are fixed.

Comment thread contract/models/contract.py Resolved
Comment thread contract/models/contract_line.py Resolved
Comment thread contract/models/contract_line.py Resolved
Comment thread contract/models/contract_line.py Resolved
Comment thread contract/models/contract_line.py Resolved

@fcvalgar fcvalgar 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.

Hi @Borruso ,

During the functional testing of this migration, we detected a permissions issue.

Steps to reproduce:

  1. Log in with a user who has Accounting / Billing permissions (account.group_account_invoice), without Accounting Administrator rights.
  2. New contract.
  3. Try to add a new contract line.

Current behavior (20.0):
The user cannot create contract lines unless Accounting Administrator permissions are granted.

Expected behavior:
Users with Billing permissions should be able to create and manage contract lines without requiring administrator rights, as we have verified in our 19.0 environment.

Technical findings:

The relevant configuration appears to be in contract/security/ir.access.csv, specifically the contract_line_user entry:

contract_line_user,Recurring user,model_contract_line,account.group_account_invoice,r,

This entry grants read-only access to contract.line.

However, the equivalent ACL in 19.0 was also read-only, so the issue may be related to changes in the security framework, effective group permissions, or the contract line creation workflow.

Could you please review this behavior and restore the expected permissions for Billing users?

It would also be useful to add a regression test verifying that a Billing user can create and edit contract lines without Accounting Administrator rights.

Thanks for your work on this migration!

image

Comment thread contract/security/ir.access.csv Resolved
@Borruso
Borruso requested a review from fcvalgar November 13, 2026 12:09
@rousseldenis

Copy link
Copy Markdown
Contributor

This has quite a bunch of hallucinations. It'd be respectfull to other contributors to review before publishing it rather than expecting others to put in the effort you haven't.

@chienandalu ?

@rousseldenis

Copy link
Copy Markdown
Contributor

@Borruso Are you plenty conscious of what is a maintainer ?

I think you are not the maintainer of this one.

@max3903 You've asked for maintainers on this. But which ones ? This is a big one and a lot of people contributed.

@Borruso

Borruso commented Nov 13, 2026

Copy link
Copy Markdown
Author

@Borruso Are you plenty conscious of what is a maintainer ?

I think you are not the maintainer of this one.

@max3903 You've asked for maintainers on this. But which ones ? This is a big one and a lot of people contributed.

sorry I misunderstood they said to add the maintainers tag and I added myself by mistake

@max3903

max3903 commented Nov 13, 2026

Copy link
Copy Markdown
Member

@Borruso Are you plenty conscious of what is a maintainer ?

I think you are not the maintainer of this one.

@max3903 You've asked for maintainers on this. But which ones ? This is a big one and a lot of people contributed.

Let's start with the original author...

@chienandalu chienandalu 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.

Hi, @Borruso

I found some major issues regarding security, the rules+access don't seem to be merged properly. Did you use https://github.com/odoo/odoo/blob/20.0/odoo/upgrade_code/19.4-00-ir-access.py ?

Comment thread contract/models/contract.py Resolved
Comment thread contract/security/contract_security.xml Resolved
Comment thread contract/tests/test_portal.py Resolved
Comment thread contract/tests/test_contract.py Resolved
Comment thread contract/tests/test_contract.py Resolved
Comment thread contract/models/contract_line.py Resolved
Comment thread contract/data/portal_entry_data.xml Resolved
Comment thread contract/data/portal_entry_data.xml Resolved
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.