i want to question ,
i will add sequence 'KODE CABANG' in Purchase Order (PO) Sequence, with format PO like
PO+'KODE CABANG'+2 DIGIT YEAR+2 DIGIT MONTH+5 DIGIT SEQUENCE ...
i have code 'KODE CABANG' like MML, HHO, ULZ, DBB ...
so, code 'KODE CABANG' show in field prefix or suffix in sequence form ..
what i do ?
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.
ok thanks ,
it works, with add method create, like :
def create(self, cr, uid, vals, context=None):
seq = self.pool.get('res.partner').browse(cr, uid, vals['partner_id'])
vals['name'] = self.pool.get('ir.sequence').get(cr, uid, seq.kd_sequence.code)
return super(purchase_order, self).create(cr, uid, vals, context=context)
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
|Asked: 12/16/14, 9:44 PM|
|Seen: 1179 times|
|Last updated: 3/16/15, 8:10 AM|