In Odoo 17, the ir.sequence model and next_by_code() method are used to generate unique reference numbers automatically. When a record is created, the system fetches the next sequence value based on the sequence code. This helps create organized document numbers for sales orders, invoices, projects, manufacturing orders, and custom modules.