How to Implement Custom Invoice Numbering Based on Product Category in Odoo 16?

67 views Asked by At

I'm currently developing a module in Odoo 16 and facing a challenge that I believe requires community expertise. My goal is to create a system for generating custom invoice numbers that are based on the product category, with a specific focus on color categories (e.g., red, blue, black). The idea is to have a unique invoice numbering system where each color category has its own prefix and a sequence number that increments with each new invoice. For example, adding a red car to an invoice would generate invoice numbers like RC0004, RC0005, and so on, while adding a blue car would result in BC0048, BC0049, etc.

Here are the key requirements I'm trying to meet:

Dynamic Category Creation: I need to be able to create product categories (in this case, colors) dynamically from the front-end, along with specifying the starting number for the invoice sequence in that category.

Sequential Numbering: Each category should have its own sequential numbering that starts from the specified number and increments by 1 for every new invoice created within that category.

Concurrency Handling: The system should be capable of handling situations where two sellers might create an invoice for the same category at the same time, ensuring that each invoice gets a unique number without any overlap.

I've considered customizing the ir.sequence model to achieve this but am unsure how to approach the dynamic nature of category creation and linking it to a specific sequence that can handle concurrency properly.

Has anyone implemented something similar or has any insights on how to best approach this problem in Odoo 16? I'm looking for guidance on the module structure, models to extend or create, and any potential pitfalls I should be aware of, especially regarding the concurrency issue.

Thank you in advance for your help and suggestions!

0

There are 0 answers