Skip to content

[13.0][MIG] base_exception: Migration to 13.0 - #1920

Merged
OCA-git-bot merged 29 commits into
OCA:13.0from
Tecnativa:13.0-mig-base_exception
Nov 4, 2020
Merged

OCA-git-bot merged 29 commits into
OCA:13.0from
Tecnativa:13.0-mig-base_exception

Conversation

@joao-p-marques

@joao-p-marques joao-p-marques commented Oct 30, 2020

Copy link
Copy Markdown
Member

Superseeds #1760
Ran pre-commit and squashed latest commits that attended comments in previous PR.

@Tecnativa
TT21615

ping @pedrobaeza

mourad-ehm and others added 28 commits October 30, 2020 15:21
* Fix menu in base_exception

* Fix base_exception/views/base_exception_view.xml
…lled by constraint methods

'detect_exception' can be called on an empty recordset.
Defines a new mechanism to build odoo classes that are only
defined during testing.
- Show menu only to Exception Rule Managers
- Use sequence and active widgets on tree view
- Updated form to use sheet
improve the perfs dramastically when there is a lot of records
No more empty fields after changing type.
Add a note about safe_eval
[IMP] Computed exception descriptions field, to display better help messages

[IMP] Exceptions shouldn't be copied
This recently added feature is counter intuitive, error prone and is
already causing bugs in sale_workflow.
The goal of the modified method is to create or remove the relationship
(in the M2m relation tabel) between the tested model (such as
sale_order) and the exception rules. When the ORM writes on
ExceptionRule.sale_ids (using the example of sale_exception), it will
first proceeds with these updates:

* an UPDATE on exception_rule to set the write_date
* INSERT or DELETE on the relation table
* but then, as "write" is called on the exception rule, the ORM will
  trigger the api.depends to recompute all the "main_exception_ids"
  of the records (sales, ...) related to it, leading to an UPDATE
  for each sale order

We end up with RowExclusiveLock on such records:

* All the records of the relation table added / deleted for the current
sale order
* All the records of exception_rule matching the current sale order
* All the records of sale_order related to the exception rules matching
the current sale order

The first one is expected, the next 2 are not. We can remove the lock on
the exception_rule table by removing `_log_access`, however in any case,
the main_exception_ids computed field will continue to lock many sale
orders, effectively preventing 2 sales orders with the same exception
to be confirmed at the same time.

Reversing the write by writing on SaleOrder instead of ExceptionRule
fixes the 2 unexpected locks. It should not result in more queries: the
"to remove" part generates a DELETE on the relation table for the rule
to remove and the "to add" part generates an INSERT for the rule to add,
both will be exactly the same in both cases.

Related to OCA#1642
Replaces OCA#1638
@joao-p-marques joao-p-marques mentioned this pull request Oct 30, 2020
29 tasks
@joao-p-marques
joao-p-marques force-pushed the 13.0-mig-base_exception branch from 6e97974 to cbc4aa4 Compare October 30, 2020 15:34
@joao-p-marques

Copy link
Copy Markdown
Member Author

Also updated README

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

Code review 👍

Comment thread base_exception/tests/purchase_test.py
@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). 🤖

@pedrobaeza

Copy link
Copy Markdown
Member

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 13.0-ocabot-merge-pr-1920-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 5cba515 into OCA:13.0 Nov 4, 2020
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at fd6ed9a. Thanks a lot for contributing to OCA. ❤️

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.