问题 I am setting up default value of analytics_id in account.move.line by below code class account_move_line(models.Model): _inherit = 'account.move.line' _name = "account.move.line" def _get_default_account(self, cr, uid, context=None): obj = self.pool.get('account.move') value = obj.browse(cr, uid, uid) if value.move_id.debit>0 or value.move_id.credit<0: res = self.pool.get('account.analytic.plan.instance').search(cr, uid, [('code','=','LAL')], context=context) return res and res[0] or False