• 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
    因为有写好的模块,所以可以直接调用


  • 相关阅读:
    ABAP 动态内表构建 Dynamic internal table
    RFC权限分配
    ERP从业来的总结
    WORD中插入VISIO图形,打印乱码解决
    SAP中程序间的相互调用,SUBMIT关键字的用法
    SDva01的屏幕增强
    STL中的binder
    C++中的new
    C++数组中多态问题分析
    Gdiplus中实现双Buffer绘图
  • 原文地址:https://www.cnblogs.com/1314520xh/p/6941242.html
Copyright © 2020-2023  润新知