Skip to content

Commit 87712b7

Browse files
committed
[FIX] do not allow divide by zero
1 parent 21b220d commit 87712b7

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "odoo-rapid-quant"
3-
version = "0.1.4"
3+
version = "0.1.5"
44
license = "LGPL-3.0-or-later"
55
edition = "2024"
66
rust-version = "1.85"

src/dialect/v15.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ impl OdooAdapter for Adapter {
132132
AND product_template.type = 'product'
133133
AND mrp_bom.active is true
134134
AND mrp_bom.type in ('normal', 'phantom')
135+
AND mrp_bom.product_qty > 0
135136
",
136137
);
137138

@@ -197,6 +198,10 @@ impl OdooAdapter for Adapter {
197198
line_product_product.active is true
198199
AND
199200
line_product_template.type = 'product'
201+
AND
202+
mrp_bom.product_qty > 0
203+
AND
204+
mrp_bom_line.product_qty > 0
200205
",
201206
);
202207

src/product.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ impl Graph {
411411
// Iterate dependencies (incoming edges)
412412
for edge in graph.edges_directed(product, petgraph::Incoming) {
413413
let (dependency, required_qty) = (edge.source(), *edge.weight());
414+
if required_qty <= Decimal::ZERO {
415+
continue;
416+
}
414417
if let Some(dependency_stock) = stock_cache.get(&dependency) {
415418
let dependency_dp = catalogue.get(&product).unwrap_or_else(|| {
416419
panic!(

0 commit comments

Comments
 (0)