@Heru
As per your requirement you have different "Kode Cabang", so I think you will have to create those many sequence to to identify as per different "codes". Then while in create method you will have to identify the appropriate sequence and call it for the record creation.

If your requirement is very specific to PO (not to other sequences), then I would advise that you don't touch the ir.sequence. Make the sequence of PO to supply 2 DIGIT YEAR+2 DIGIT MONTH+5 DIGIT SEQUENCE. Then in the code where PO name is applied (it is during create method in v7.0, see odoo/addons/purchase/purchase.py), put the "PO"+KODE CABANG as a prefix to the already provided string.

If you need the KODE CABANG to be applicable for more than one sequences, then maybe it is worth considering to inherit ir.sequence and enhance it's _next method (see odoo/openerp/addons/base/ir/ir_sequence.py). The challange is how would you provide the information for KODE CABANG. Some models actually called _next in their default_get, which is called even before the model instance is created.

Note that when the PO has been created, I presume the field for KODE CABANG will still be editable until a certain state. You may need to make the assignment of PO number later in the process (not in create) if you want to get the most up to date KODE CABANG.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just
use the commenting tool. Please remember that you can always revise your answers
- no need to answer the same question twice. Also, please don't forget to vote
- it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines