diff options
| author | Raphael Collet <rco@odoo.com> | 2019-10-15 13:26:22 +0000 |
|---|---|---|
| committer | fw-bot <otis@odoo.com> | 2019-10-22 14:55:51 +0000 |
| commit | c8dca514e619741c9235fa5ad3e53693f65079e5 (patch) | |
| tree | d5e1e683494c59a6189158daaccff0709ffa116e /addons/delivery | |
| parent | 5efd768b3da3ce38338ae6a33cd1c9c87efc7424 (diff) | |
[FIX] fields: `compute_sudo` defaults to True for stored fields only
The default `compute_sudo=True` makes sense for recomputing stored
fields that are indirectly related to a business operation. This
ensures that the recomputation of the field does not break an operation
that is not aware of the fields to recompute.
However, computing non-stored fields in superuser mode is usually not
necessary. It even leads to unexpected values: counting a partner's
sales orders does not give the same result in superuser mode as in
normal mode. That is why non-stored fields are not computed in
superuser mode by default.
[FIX] account, delivery, event, hr_recruitment, point_of_sale, stock:
adapt the model definition to make all fields with the same compute
method have the same value for `compute_sudo`.
[FIX] sale: split the computation of `invoice_ids`, `invoice_count`
(non-stored) and `invoice_status` (stored), as no code is actually
shared.
closes odoo/odoo#39195
X-original-commit: 843fd38a97f02b49dc09d7f55919072d272fd80e
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Diffstat (limited to 'addons/delivery')
| -rw-r--r-- | addons/delivery/models/sale_order.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/addons/delivery/models/sale_order.py b/addons/delivery/models/sale_order.py index 464b36aa726..ff3eb2c1a35 100644 --- a/addons/delivery/models/sale_order.py +++ b/addons/delivery/models/sale_order.py @@ -122,14 +122,14 @@ class SaleOrder(models.Model): post = u'\N{NO-BREAK SPACE}{symbol}'.format(symbol=self.currency_id.symbol or '') return u' {pre}{0}{post}'.format(amount, pre=pre, post=post) - @api.depends('state', 'order_line.invoice_status', 'order_line.invoice_lines', - 'order_line.is_delivery', 'order_line.is_downpayment', 'order_line.product_id.invoice_policy') - def _get_invoiced(self): - super(SaleOrder, self)._get_invoiced() + @api.depends('order_line.is_delivery', 'order_line.is_downpayment', + 'order_line.product_id.invoice_policy') + def _get_invoice_status(self): + super()._get_invoice_status() for order in self: - order_line = order.order_line.filtered(lambda x: not x.is_delivery and not x.is_downpayment and not x.display_type) - if all(line.product_id.invoice_policy == 'delivery' and line.invoice_status == 'no' for line in order_line): - order.update({'invoice_status': 'no'}) + order_lines = order.order_line.filtered(lambda x: not x.is_delivery and not x.is_downpayment and not x.display_type) + if all(line.product_id.invoice_policy == 'delivery' and line.invoice_status == 'no' for line in order_lines): + order.invoice_status = 'no' class SaleOrderLine(models.Model): |
