zoukankan      html  css  js  c++  java
  • 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
    因为有写好的模块,所以可以直接调用


  • 相关阅读:
    How to Compile Java DBus
    BZOJ 2783 JLOI 2012 树 乘+二分法
    Robotium原则的实施源代码分析
    基本的负载均衡算法
    人大、上财、复旦、上交四校2013年应届金融硕士就业去向
    2014届上财金融硕士就业情况
    三跨),总分420+
    复旦金融专硕和上财金融专硕
    一个三跨考生三战上海财经大学金融硕士的考研经验
    董某某
  • 原文地址:https://www.cnblogs.com/1314520xh/p/6941242.html
Copyright © 2011-2022 走看看