采购订单已经有序列,我的第一个问题是:
如何创建第二个序列?
如何仅针对特定合作伙伴限制此顺序?
这是我使用的代码,但显然是第一个序列的覆盖。
class purchase_order(osv.osv):
_inherit = 'purchase.order'
_name = 'purchase.order'
def create(self, cr, uid,vals, context={}):
vals['bic_code'] = self.pool.get('ir.sequence').get(cr, uid, 'purchase.order')
res = super(purchase_order, self).create(cr, uid, vals, context)
return res
def copy(self, cr, uid, id, default=None, context=None):
default.update({
'bic_code': self.pool.get('ir.sequence').get(cr, uid, 'purchase.order')
})
return super(porchase_order, self).copy(cr, uid, id, default, context)
_columns = {
'bic_code': fields.char('Referencia Bic', size=64, readonly=True),
}
_defaults = {
'bic_code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'purchase.order'),
}
采购订单()
XML序列
<?xml version="1.0" encoding="utf-8"?>
<record model="ir.sequence.type" id="seq_type_purchase_bic">
<field name="name">number_bic_sequence</field>
<field name="code">purchase.order.bic1</field>
</record>
<record model="ir.sequence" id="seq_purchase_bic">
<field name="name">number_bic_sequence</field>
<field name="code">purchase.order.bic1</field>
<field name="prefix">10670-</field>
<field name="padding">5</field>
</record>
</data>
XML 视图
<?xml version="1.0" encoding="utf-8"?>
<record id="view_bic_form" model="ir.ui.view">
<field name="name">purchase.bic.order.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field name="arch" type="xml">
<xpath expr="/form/group/field[@name='date_order']" position="after">
<field name="bic_code" />
</xpath>
</field>
</record>
</data>
非常感谢你能给我的任何帮助