diff options
| author | Raphael Collet <rco@odoo.com> | 2019-08-14 07:35:49 +0000 |
|---|---|---|
| committer | Denis Ledoux <dle@odoo.com> | 2019-08-20 12:43:59 +0000 |
| commit | 9920f20e4c7753bc17bea71dea3a90f7de687196 (patch) | |
| tree | 6a3d0258c10a8ccb1d85949ddafdeb070de78121 /addons/sms/models | |
| parent | e28d3aa4d3851d72deba08c236072d002f83216a (diff) | |
[IMP] models: ORM speedup
This branch is the combination of several optimizations in the ORM:
* store field values once in the cache: the cache reflects more
faithfully the database, only fields that explicitly depend on the
context have an extra indirection in the cache;
* delay recomputations by default: use method `recompute` to explicitly
flush out pending recomputations;
* delay updates in method `write`: updates are stored in a data
structure that can be flushed efficiently to the database with method
`flush` (which also flush out recomputations);
* make method `modified` take advantage of inverse fields to inverse
dependencies;
* filter records by evaluating a domain on records in Python;
* a computed field with `readonly=False` behaves like a normal field
with an onchange method;
* computed fields are computed in superuser mode by default.
Work done by Toufik Ben Jaa, Raphael Collet, Denis Ledoux and Fabien
Pinckaers.
closes odoo/odoo#35659
Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
Diffstat (limited to 'addons/sms/models')
| -rw-r--r-- | addons/sms/models/mail_notification.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/addons/sms/models/mail_notification.py b/addons/sms/models/mail_notification.py index c45981ea0b0..6ab3dbecff3 100644 --- a/addons/sms/models/mail_notification.py +++ b/addons/sms/models/mail_notification.py @@ -16,3 +16,22 @@ class Notification(models.Model): ('sms_credit', 'Insufficient Credit'), ('sms_server', 'Server Error')] ) + # Though this is an interesting case: + # On sms.resend.recipient, partner_id depends on mail.notification.partner_id as it is defined as a related + # fields.Many2one('res.partner', 'Partner', related='notification_id.res_partner_id', readonly=True) + # The below is to add an inverse to the many2one sms.resend.recipient.notification_id + # so it maintains a list of sms.resend.recipient.partner_id to invalidate + # when modifying the partner_id of mail.notification. Otherwise the ORM has to do a plain search to find the sms.resend.recipient + # which have as notification id the one that has been modified + # Though: + # - We already discussed the matter it would rather be more interesting to do this automatically for these cases, + # with a kind of virtual one2many the developer/user doesn't know about, + # so the developer doesnt have to create it himself for this technical/performance reason + # - In this case, the modified happens on the creation of the mail.notification, and has it has just been created it + # would be quite safe to assume there was no `sms.resend.recipient` and we could have avoided the search, + # even without this virtual/technical one2many. + # - Besides, its a wizard, and we also discussed the possibility to stop the modified when going from a regular model to a transient model + # meaning when we update something on the record on which is based the wizard + # e.g. a related to the invoice name, something like that, + # we let the modified do its change when we specifically change the invoice on the wizard, but not when changing the name on the invoice + sms_resend_recipient_ids = fields.One2many('sms.resend.recipient', 'notification_id', strong='SMS recipients to resend') |
