Decouple reprint counts from label weights

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-20 11:08:15 +03:30
parent a5cb3ef35f
commit 71fff09b85
2 changed files with 41 additions and 12 deletions

View File

@@ -55,16 +55,13 @@ class Order(models.Model):
self.box_count = math.ceil(self.canister_count / self.canisters_per_box)
def set_counts(self, canister_count=None, box_count=None):
"""Edit label counts; keep total_weight aligned with canisters."""
"""Edit print quantities only; total_weight stays the packaging truth."""
if canister_count is not None:
self.canister_count = canister_count
self.total_weight = canister_count * self.canister_weight
if box_count is not None:
self.box_count = box_count
def save(self, *args, **kwargs):
if not self.canister_count and self.total_weight and self.canister_weight:
self.apply_weight()
# Mixed sheets: canister + box labels share pages; total in canister_pages
n = self.canister_count + self.box_count
self.canister_pages = math.ceil(n / 4) if n else 0