odoo之自动生成编号问题

单独的seq。xml文件

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1"><!-- Sequences for demo_contract_lx -->
<record id="seq_type_demo_contract_lx" model="ir.sequence.type">
<field name="name">Demo contract lx</field>
<field name="code">demo.contract.lx</field>
</record>
<record id="seq_demo_contract_lx" model="ir.sequence">
<field name="name">Demo contract lx</field>
<field name="code">demo.contract.lx</field>
<field name="prefix">FSDLX%(year)s</field>
<field name="padding">5</field>
<field name="company_id" eval="False"/>
<!--<field name="implementation">yynum</field>-->
</record> <record id="seq_type_sigining_contract" model="ir.sequence.type">
<field name="name">Sigining contract</field>
<field name="code">sigining.contract</field>
</record>
<record id="seq_sigining_contract" model="ir.sequence">
<field name="name">Sigining contract</field>
<field name="code">sigining.contract</field>
<field name="prefix">FSD%(year)s</field>
<field name="padding">5</field>
<field name="company_id" eval="False"/>
<!--<field name="implementation">yynum</field>-->
</record> </data></openerp> 在py里写
# 'pname': fields.related('product_id', 'pname',relation='product.product', type="char", string='Product Name',readonly=True,),
_columns = { } _defaults={
'state':'draft',
} def create(self,cr,uid,vals,context=None):
if context is None:
context ={}
if vals.get('contract_origin', '/') == '/':
vals['contract_origin'] = self.pool.get('ir.sequence').get(cr, uid, 'sigining.contract', context=context) or '/'
new_id=super(sigining_contract,self).create(cr,uid,vals,context=context)
return new_id
因为有写好的模块,所以可以直接调用

上一篇:ubuntu鼠标突然不能使用的解决方法


下一篇:使用INTERVAL YEAR TO MONTH类型