From 5a5e310a83a16350614abe61cb329ed19c232bf4 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Wed, 20 May 2026 22:43:29 -0400 Subject: [PATCH] feat(fusion_repairs): repair.order reference format -> RO-YYYYMM-NN Replaced the picking-type default reference (BR-WA/RO/00010) with a date-based monthly-resetting sequence: RO-202605-01, RO-202605-02, ... where YYYY is the year and MM is the zero-padded month. The counter resets to 01 every time the month rolls over. Implementation: - New ir.sequence 'fusion.repair.order.monthly' with prefix 'RO-%(year)s%(month)s-', padding=2, use_date_range=True (Odoo creates one ir.sequence.date_range per month, each with its own number_next) - repair.order.create() override pre-fills vals['name'] with the new sequence BEFORE super(), so Odoo's native picking-type sequence assignment (which only fires when name is empty / 'New') is bypassed Verified on local westin-v19: three back-to-back creates produced RO-202605-01 / -02 / -03. Existing records (pre-upgrade) keep their old BR-WA/RO/##### references - this only affects repairs created from this version onward. Bumped to 19.0.1.0.4. Co-authored-by: Cursor --- fusion_repairs/__manifest__.py | 2 +- fusion_repairs/data/ir_sequence_data.xml | 16 ++++++++++++++++ fusion_repairs/models/repair_order.py | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/fusion_repairs/__manifest__.py b/fusion_repairs/__manifest__.py index 19232951..1e81bce9 100644 --- a/fusion_repairs/__manifest__.py +++ b/fusion_repairs/__manifest__.py @@ -4,7 +4,7 @@ { 'name': 'Fusion Repairs', - 'version': '19.0.1.0.3', + 'version': '19.0.1.0.4', 'category': 'Inventory/Repairs', 'summary': 'Guided medical equipment repair intake, dispatch, maintenance, and self-service portal', 'description': """ diff --git a/fusion_repairs/data/ir_sequence_data.xml b/fusion_repairs/data/ir_sequence_data.xml index dd24383f..6123a864 100644 --- a/fusion_repairs/data/ir_sequence_data.xml +++ b/fusion_repairs/data/ir_sequence_data.xml @@ -23,5 +23,21 @@ 1 + + + + Repair Order (RO-YYYYMM-NN) + fusion.repair.order.monthly + RO-%(year)s%(month)s- + + 2 + 1 + 1 + + + diff --git a/fusion_repairs/models/repair_order.py b/fusion_repairs/models/repair_order.py index a017112d..d609b67b 100644 --- a/fusion_repairs/models/repair_order.py +++ b/fusion_repairs/models/repair_order.py @@ -28,6 +28,22 @@ class RepairOrder(models.Model): _inherit = 'repair.order' + # ------------------------------------------------------------------ + # CREATE - replace the picking-type default sequence with our + # date-based RO-YYYYMM-NN reference. We set vals['name'] BEFORE + # super() so Odoo's native create() (which only assigns the picking + # type sequence when name is empty or 'New') skips its own numbering. + # ------------------------------------------------------------------ + @api.model_create_multi + def create(self, vals_list): + Sequence = self.env['ir.sequence'].sudo() + for vals in vals_list: + if not vals.get('name') or vals.get('name') == 'New': + next_name = Sequence.next_by_code('fusion.repair.order.monthly') + if next_name: + vals['name'] = next_name + return super().create(vals_list) + # ------------------------------------------------------------------ # INTAKE METADATA # ------------------------------------------------------------------