diff options
| author | William Henrotin <whe@odoo.com> | 2021-05-06 13:33:32 +0000 |
|---|---|---|
| committer | William Henrotin <whe@odoo.com> | 2021-05-06 13:38:12 +0000 |
| commit | c7b32e0795bc1573d81563f31a75fa44c64b39c2 (patch) | |
| tree | 8810aa6179bb8369a692abd37a1fd49fbb3b55c1 /addons/purchase_stock | |
| parent | f91ba797469f4a132b145b907c056a1acd6805de (diff) | |
[FIX] stock,mrp,purchase: bypass optionnal delay description
The _get_lead_days() method does two things:
1. Compute the lead day depending on the product to replenish
2. Build a string explaining what are the parts of this day number
This second part is optional at the Replenishment report opening.
As the string is translatable, this impact quite significantly the
performance of this opening.
closes odoo/odoo#70351
Opw: 2519528
Related: odoo/enterprise#18202
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Diffstat (limited to 'addons/purchase_stock')
| -rw-r--r-- | addons/purchase_stock/models/stock_rule.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/addons/purchase_stock/models/stock_rule.py b/addons/purchase_stock/models/stock_rule.py index f6a14616e50..2064f76b6e8 100644 --- a/addons/purchase_stock/models/stock_rule.py +++ b/addons/purchase_stock/models/stock_rule.py @@ -148,18 +148,21 @@ class StockRule(models.Model): purpose in order to indicate that those options are available. """ delay, delay_description = super()._get_lead_days(product) + bypass_delay_description = self.env.context.get('bypass_delay_description') buy_rule = self.filtered(lambda r: r.action == 'buy') seller = product._prepare_sellers() if not buy_rule or not seller: return delay, delay_description buy_rule.ensure_one() supplier_delay = seller[0].delay - if supplier_delay: + if supplier_delay and not bypass_delay_description: delay_description += '<tr><td>%s</td><td class="text-right">+ %d %s</td></tr>' % (_('Vendor Lead Time'), supplier_delay, _('day(s)')) security_delay = buy_rule.picking_type_id.company_id.po_lead - delay_description += '<tr><td>%s</td><td class="text-right">+ %d %s</td></tr>' % (_('Purchase Security Lead Time'), security_delay, _('day(s)')) + if not bypass_delay_description: + delay_description += '<tr><td>%s</td><td class="text-right">+ %d %s</td></tr>' % (_('Purchase Security Lead Time'), security_delay, _('day(s)')) days_to_purchase = buy_rule.company_id.days_to_purchase - delay_description += '<tr><td>%s</td><td class="text-right">+ %d %s</td></tr>' % (_('Days to Purchase'), days_to_purchase, _('day(s)')) + if not bypass_delay_description: + delay_description += '<tr><td>%s</td><td class="text-right">+ %d %s</td></tr>' % (_('Days to Purchase'), days_to_purchase, _('day(s)')) return delay + supplier_delay + security_delay + days_to_purchase, delay_description @api.model |
