“account_invoice.py 的 python 代码,我想知道如何在 OpenERP 中初始化一个默认的 one2many 字段”
class account_invoice(osv.osv):
def _tax_line_default(self, cr ,uid, context=None):
obj= self.pool.get('account.invoice.tax')
ids= obj.search(self, cr, uid)
obj.write(cr, uid, ids[0], {'name' : 'droit de timbre','amount':0.400})
res =obj.browse(cr, uid, ids[0])
return res.name_get(cr, uid, ids[0], context)
_ columns = {
'tax_line': fields.one2many('account.invoice.tax', 'invoice_id', 'Tax Lines', readonly=True, states={'draft':[('readonly',False)]})
}
_defaults = {
'tax_line':_tax_line_default,
}
http://nsa33.casimages.com/img/2013/05/17/130517043059690422.png
http://nsa33.casimages.com/img/2013/05/17/130517053356530066.png