콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
7 답글
10049 화면

This is my code-------

class account_voucher(osv.Model):

_inherit = "account.voucher"

_columns={

'sequence_number':fields.char('Sequence Number'),

}

def create(self, cr, uid, vals, context=None):

vals['sequence_number'] = self.pool.get('ir.sequence').get(cr, uid,'account.voucher')

return super(account_voucher, self).create(cr, uid, vals, context=context)

_defaults={

'sequence_number': lambda obj, cr, uid, context: ' /',

}

account_voucher()


=============================






<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data noupdate="1">

<!-- Sequences for loan_id -->

<record id="seq_cloan_code_inh1" model="ir.sequence.type">

<field name="name">SEQ ID</field>

<field name="code">account.voucher</field>

</record>

<record id="seq_cloan_code_inh2" model="ir.sequence">

<field name="name">SEQ ID</field>

<field name="code">account.voucher</field>

<field name="prefix">SEQ</field>

<field name="padding">2</field>

</record>

</data>

</openerp>

아바타
취소
베스트 답변

Hi,

For starting a sequence from a particular number you can give the starting number(number_next) when you define sequence(ir.sequence) in xml file.

For Eg (you want to start from 5000) :

<record id="seq_brand" model="ir.sequence">

<field name="name">Brand</field>

<field name="code">product.brand</field> # name of type

<field name="padding">5</field>

<field name="number_next">50000</field> # first number

<field name="number_increment">1</field> # increment by

</record>


Hope this helps....

아바타
취소
작성자

Thanks it working........

베스트 답변



Hello,

You can set your sequence next number from setting -> sequence and identifiers -> sequence.

Set next number field value as per your requirement.


This is also you can set by code when you define sequence.

Thanks.

Openies


아바타
취소
작성자

Thanks

베스트 답변

By using sql query to alter the sequence

ALTER SEQUENCE seq_cloan_code_inh2  RESTART WITH 5000;

Note:
When creating a sequence manually, the naming format used is  'ir_sequence_DATABASE_ID'  e.g. ir_sequence_071 for a sequence with db id=71.

아바타
취소
작성자

Thanks