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/delivery/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/delivery/models')
| -rw-r--r-- | addons/delivery/models/sale_order.py | 2 | ||||
| -rw-r--r-- | addons/delivery/models/stock_move.py | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/addons/delivery/models/sale_order.py b/addons/delivery/models/sale_order.py index 879c3a356ec..86f05513efc 100644 --- a/addons/delivery/models/sale_order.py +++ b/addons/delivery/models/sale_order.py @@ -30,6 +30,8 @@ class SaleOrder(models.Model): delivery_line = self.order_line.filtered('is_delivery') if delivery_line: self.delivery_set = True + else: + self.delivery_set = False @api.onchange('order_line', 'partner_id') def onchange_order_line(self): diff --git a/addons/delivery/models/stock_move.py b/addons/delivery/models/stock_move.py index 6afe8a6c210..39d4707301a 100644 --- a/addons/delivery/models/stock_move.py +++ b/addons/delivery/models/stock_move.py @@ -12,8 +12,10 @@ class StockMove(models.Model): @api.depends('product_id', 'product_uom_qty', 'product_uom') def _cal_move_weight(self): - for move in self.filtered(lambda moves: moves.product_id.weight > 0.00): + moves_with_weight = self.filtered(lambda moves: moves.product_id.weight > 0.00) + for move in moves_with_weight: move.weight = (move.product_qty * move.product_id.weight) + (self - moves_with_weight).weight = 0 def _get_new_picking_values(self): vals = super(StockMove, self)._get_new_picking_values() |
