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 #1642
Replaces #1638
Fixing #1134.
Odoo stores values of computed fields at the end of the transaction
only, as such performing a 'read()' to make a data snapshot on the record
created in the current transaction doesn't return the expected result
regarding these fields.
Also as a side-effect 'read()' alters the environment cache and break the
values on the record inducing issues in the whole user
transaction/workflow.
This fix replaces the use of 'read()' to do the data snapshot directly
from the cache of the record (computed values are already there).
* Add default stage_id logic that returns lowest sequence stage associated with
inheriting model and update unit tests accordingly
* Improve _read_group_stage_ids unit test
* Implement latest abstract model testing strategy
* Update depends to `base`
* Update priority selections to match Odoo guidelines
* Update comment block to triple double quotes
* Update `kanban_user_id` to `user_id` in code and view
* Update README to incorporate use of mode in example view
* Add Kanban-compatible stage model base.kanban.stage
* Add views, menu items, actions, and access controls needed to manage base.kanban.stage records
* Add abstract model base.kanban.abstract that other models can inherit from to gain Kanban stage functionality
* Add base Kanban view base_kanban_abstract_view_kanban, which can be customized as needed for use with models that inherit from base.kanban.abstract
* Add model base.kanban.abstract.tester, which is needed for base.kanban.abstract unit tests