Commit 470a1f1
committed
[FIX] mrp: avoid crash when printing BOM with 0-quantity byproducts
Issue:
Printing the BOM crashes when one of the byproduct quantity is set to 0
Steps to reproduce:
- Open the manufactoring app
- Go to settings and activate by-product settings
- Go to Products > Bills of Materials
- Open a BOM
- Put the quantity of one the by-product by 0
- Click on overview
- Click on the print button
Cause:
In the `mrp_report_bom_structure.xml` template, there is this division:
- `<td class="text-end" t-esc="byproduct['bom_cost'] / byproduct['quantity']" t-options='{"widget": "monetary", "display_currency": currency}'/>`
without checking if `byproduct['quantity']` is different than 0.
Solution:
Added the check on `byproduct['quantity']` in the foreach
Additional notes:
Since it makes no real sense to have a non-zero BoM cost associated with a byproduct whose quantity is zero, the cost is set to 0 when the quantity is 0.
opw-4853525
closes odoo#217819
X-original-commit: 1ef366f
Signed-off-by: Tiffany Chang (tic) <tic@odoo.com>
Signed-off-by: Maxime Noirhomme (noma) <noma@odoo.com>1 parent 188a3fe commit 470a1f1
2 files changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | | - | |
| 421 | + | |
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
0 commit comments